Answer the question
In order to leave comments, you need to log in
.htaccess, www to non-www redirect redirects from inner pages to home page, why?
Hello. My .htaccess is configured to redirect from www to non-www. It works, but from all internal pages (in case of entering the address from www) it redirects to the main one. I tried different options, it did not work out.
Here is my file (it also uses a redirect from http to https and with a slash at the end to without a slash at the end):
AddDefaultCharset utf-8
Options -Indexes
RewriteEngine on
RewriteBase /
# Редирект с www на без www
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^.*$ https://%1/$1 [R=301,L]
# Редирект с http на https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Редирект со слешем на конце на без слеша на конце
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [L]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question