301 redirect from non www to www issue

Posted by esmitex on Server Fault See other posts from Server Fault or by esmitex
Published on 2013-10-26T17:02:26Z Indexed on 2013/10/30 9:57 UTC
Read the original article Hit count: 271

Filed under:
|
|

I have been trying to set a 301 redirect from a non www to a www domain since yesterday but it only cause problems on my site. I first tried it from the control panel of the website, then by modifying the .htaccess file with the following:

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^mydomain.com [nc]
rewriterule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc]

My site is based on wordpress, the first problem that occurred was that I could not access my backend anymore… when I was trying to log in the page would just reload itself and then there was an endless loop and the whole site was unaccessible. After removing these few lines, everything was fine.

© Server Fault or respective owner

Related posts about .htaccess

Related posts about www