We are running an EE site which is successfully stripping the /index.php from the URL using the following rewrite rule:
RewriteCond $1 !^(docs|index.php|sitemap.php) [NC] RewriteRule ^(.*)$ /index.php/$1 [L]
I now need to get the site to redirect from the non www (example.com) version to the www. (www.example.com) version of the site. At the moment I've tried:
RewriteCond $1 !^(docs|index\.php|sitemap\.php) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This adds the 'www.', but puts the index.php back on all pages of the site. What am I doing wrong?
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?/$1 [L]
And this strips www. of the URL. But I want to add www. Using your code causes redirections