Forum Moderators: phranque

Message Too Old, No Replies

.htaccess Rewrite to WWW Causing Timeout in Wordpress Installation

         

bouncybunny

1:54 am on Feb 27, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For years I've been using the following to successfully redirect non WWW urls.


RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]


However, having just installed Wordpress in a subdirectory, I find that it continually redirects from WWW, to non WWW, and eventually times out. No other script does this and I'm wondering if anyone has any experience of this issue with WordPress and if there is an alternate way to deal with this?

I've also tried
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

g1smd

2:07 am on Feb 27, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Wordpress has it's own redirection built in, so amend the settings within Wordpress to confirm www as the one to use.

bouncybunny

7:39 am on Feb 27, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks.

I'll see if I can get this to work.

g1smd

7:07 pm on Feb 27, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The code you supplied also works better if you add

RewriteCond %{HTTP_HOST} .


to check for non-blank host name requests (like when the request is HTTP 1.0 not 1.1).

jdMorgan

4:04 pm on Mar 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also remove the end-anchor and escape the period in the existing RewriteCond pattern.

RewriteCond %{HTTP_HOST} ^example\.com

Jim