I have a website structured:
- root
- .htaccess
- wordpress installation
- folder xxx
- wordpress
In my .htaccess I have this rule:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
The problem is that it don’t allow me to go in:
www.mywebsite.it/xxx
because a loop redirection happen.
If I erase the rule, all goes good.
How can I modify it?
I want that if user type mywebsite.it/ or mywebsite.it/xxx, it is redirected to www version.
my .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Thanks a lot.
This rule works in isolation but WordPress stuff is hijacking over it. Slightly modified rule:
RewriteEngine On
line inDOCUMENT_ROOT/.htaccess
WP permalink structure
you have site address withwww.
otherwise WP will again send it back to non-wwwIf you have any
.htaccess
below root then they should this additional line belowRewriteEngine On
line:Also test in a different browser to avoid 301 caching.