: Issue with permanent redirect implementation I have a tricky problem related to 301 redirections I badly need help with. I tried to implement these via .htaccess, but ran into trouble. The start
I have a tricky problem related to 301 redirections I badly need help with.
I tried to implement these via .htaccess, but ran into trouble.
The start of my .htaccess looks like this:
SetEnv PHP_VER 5
Options +FollowSymlinks
RewriteEngine on
# Redirect non-www to www
RewriteCond %{HTTP_HOST} !^(www.|$) [NC]
RewriteRule ^ www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#--- GENERAL ---
RewriteRule ^index.html$ index.php [L]
...
When I try to put a permanent redirect to index.php by adding R=301 in the square brackets,
I get a 404, and I have no idea where the error comes from.
More posts by @Margaret670
1 Comments
Sorted by latest first Latest Oldest Best
To force to be present in a domain name try this one instead (it's safer to have domain name hard coded):
RewriteCond %{HTTP_HOST} !=www.example.com
RewriteRule (.*) www.example.com/ [QSA,R=301,L]
A bit different version (with no domain name hard coded):
RewriteCond %{HTTP_HOST} !^www.(.*)$
RewriteRule (.*) www.%{HTTP_HOST}/ [QSA,R=301,L]
But if your configuration allows to to also accept requests for domain like meow.example.com .. then it will be redirected to meow.example.com.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.