WordPress on localhost{:port number}
I run a few Virtual Host instances on Apache that are assigned different port numbers. For example, the dev instance of this site was hosted on http://localhost:8080/.
On a new WordPress installation, if I hit http://localhost:8080/ on a browser, I will get a HTTP 301 redirect to http://localhost/ (sans port number) because of the built-in Canonical URLs feature. As you can probably tell, I wasn’t able to access the WordPress instance on port 8080.
Fortunately, Mark Jaquith has provided an aptly named Disable Canonical URL Redirection plugin.
Drop the plugin into your wp-content/plugins directory and we will then need to activate it outside the admin area by fixing the database directly (I used Sequel Pro). Here’s how:
- Locate the
wp_optionstable - Set
active_pluginstoa:1:{i:0;s:31:"disable-canonical-redirects.php";} - Change the values of
siteurlandhometo/(might not be strictly necessary)
http://localhost:8080/ should now work correctly.
Just remember to disable/remove the plugin in production environment. The SQL values you just fudged would be correctly resaved once you have access to the admin section.
14 Responses To This Post:
Hi Marvin,
Great post – works like a charm – (3) wasn’t neccesary.
/Anders
I’m glad that helped someone! :)
Heya,
I just tried this with 2.8.3 and I can’t get it to work. It will still redirect to /wordpress which 404′s.
(Sorry, forgot to finish that post):
Any idea how to get it working? I’ve tried the database hack too.
I have a couple of 2.8.3 installations working fine, so the instructions above should still work. Curiously, I just discovered that one of them does not even have the “Disable Canonical URL Redirect” plugin activated, but I can still hit
http://localhost:8082/just fine.Can you try changing
siteurlandhomein the db to include the host:port-number?[...] andere und IMHO deutlich bessere lösung habe ich auf marvin tams blog gefunden: er beschreibt das “disable canonical url redirection” plugin von mark [...]
It works.
Thank you very much Marvin.
I cannot thank you enough. I have been messing around for 2 days trying different configurations with Apache. I was initially running WAMP server on :80 using virtual hosts for seperate WP installations. I then installed IIS 7 and it hogged port :80 so I have had to configure WAMP to :8080 but couldn’t get WP to work. This worked a dream, I needed step 3 too. Thank you.
Thanks for the good info. If you have info for a fix for joomla too please email me. Thx.
Because of my ISP blocking the 80 port I had to go around this issue by using another port. Regular websites would work now, but not wordpress and joomla. I checked the HTTP headers and I noticed I was getting a 301 redirect without the port number attached. You information is very good, that fixed the wordpress redirection issue. Now it’s time to figure out Joomla.
(btw this website came out very helpful for checking the HTTP headers: http://www.rexswain.com/httpview.html. I needed to use an external tool as locally of course wordpress worked fine.)
[...] http://marvintam.com/2009/05/wordpress-on-localhost-port-number/ [...]
Brilliant. Works like a charm.
I’ve wasted hours Googling for “wordpress ssh-tunnel”
You wouldn’t believe the search term that turned up this working solution :
“wordpress url 301 ssh-tunnel”
I had to search for the plugin directory though.
If it helps someone, it’s in wp-content/plugins/
Worked brilliantly. Thank you
Thank you very much, i spent a lot of time struggling with my ADSL connection, and this tip came like a light in the end of the tunnel
hello, i’m come here..
http://www.maillotfootballpascher.com/maillot-ac-milan-ext¨¦rieur-20112012-p-917.html
Leave a Reply