Answer the question
In order to leave comments, you need to log in
How to fix .htaccess to redirect to www?
Good day to all!
I ran into such a problem - I need to organize a redirect on the site from www.example.com to example.com
I found options for how to do this, but the problem is that redirects are already configured in my htaccess. Tell me how to fix it to enable a redirect from www?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?$1 [QSA,L]
Answer the question
In order to leave comments, you need to log in
this redirect has nothing to do with the right one.
1 line includes redirects
2. if the requested filename is not equal to foul
3. redirect the entire contents of the line as a get request to the php index
# 2. Редирект без www на www
RewriteCond %{HTTP_HOST} !^www\.(.*) [NC]
# Проверяем, не содержит ли домен www (в начале URL).
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# Перенаправляем URL на домен c www.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question