Redirect to www causes infinite loop

In order to redirect all requests without “www” to the ones preceded with “www” I used these lines (found here) and put them into .htaccess.

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

Out of the blue I get an infinite redirect. I made a backup set everything locally and stuff works. I don’t have access to the website’s httpd.conf nor have any idea of what could be the issue in server’s config. Site opens with “www” in it’s name and without it just fine. Once I add the redirect everything gets broken. Why?


Source: apache

Leave a Reply