Answer the question
In order to leave comments, you need to log in
How to fix .htaccess for redirect without www?
Hello!
There is a site with .htaccess:
ErrorDocument 403 /access/forbidden
ErrorDocument 404 /page/not/found
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options -Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond $1 !^(index\.php|robots\.txt|images|style|scripts)
RewriteRule ^(.+) index.php [L]
#RewriteCond %{HTTP_HOST} !^mysite\.ru$ [NC]
#RewriteRule ^(.*)$ http://mysite.ru/$1 [R=301,L]
</IfModule>
Answer the question
In order to leave comments, you need to log in
Everything just turned out, the order of the rules failed.
Here is the correct option:
ErrorDocument 403 /access/forbidden
ErrorDocument 404 /page/not/found
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options -Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{HTTP_HOST} !^mysite\.ru$ [NC]
RewriteRule ^(.*)$ http://mysite.ru/$1 [R=301,L]
RewriteCond $1 !^(index\.php|robots\.txt|images|style|scripts)
RewriteRule ^(.+) index.php [L]
</IfModule>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question