Answer the question
In order to leave comments, you need to log in
301 redirect from http to https only works with non-www, why?
Good afternoon, I moved the site from http to https
, I can’t figure out the redirect I add
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:X-HTTPS} !1
RewriteCond %{HTTP_HOST} ^site\.ru$
RewriteRule ^(.*)$
to htaccess https://www.site.ru/$1 [R=301,L]
but in this case the redirect works only from http: //site.ru to https://www.site.ru
and from http: // www .site.ru does not redirect to https://www.site.ru Tell me
what you need to add to htaccess so that it is also redirected from www.
Initially the file looks like this:
php_flag register_globals on
ErrorDocument 404 /err404.html
ExpiresActive On
ExpiresByType image/jpg "access plus 7 day"
ExpiresByType image/jpeg "access plus 7 day"
ExpiresByType image/gif "access plus 7 day"
ExpiresByType image/png "access plus 7 day"
ExpiresByType text/css "access plus 7 day"
ExpiresByType text/html "access plus 7 day"
ExpiresByType text/javascript "access plus 7 day"
ExpiresByType application/javascript "access plus 7 day"
ExpiresDefault "access plus 7 day"
Answer the question
In order to leave comments, you need to log in
because in RewriteCond %{HTTP_HOST} they indicated that it should start (^ character) with site\.ru$
RewriteCond %{HTTP_HOST} ^site\.ru$
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.site\.ru$
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.site.ru/$1 [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question