Answer the question
In order to leave comments, you need to log in
How to write 301 redirect in htaccess file from www to non-www for directories beyond the second one?
Task
Make a 301 redirect for all pages of the site from addresses with www to addresses without www.
Now this solution works for the main and first-level sections:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</IfModule>
Answer the question
In order to leave comments, you need to log in
Hello!
Proven solution:
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question