Last active
June 7, 2018 21:18
-
-
Save DreamerKlim/c8317296e0773cbfd1fcc5225a2faaab to your computer and use it in GitHub Desktop.
mod_rewrite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
В документах панели указано следующее: | |
RewriteEngine On | |
RewriteCond %{HTTPS} off | |
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L] | |
Но существуют и другие варианты: | |
Вариант 1 * | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{SERVER_PORT} !^443$ | |
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] | |
</IfModule> | |
Вариант 2 | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{HTTPS} =on | |
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L] | |
</IfModule> | |
Вариант 3 | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{HTTP:SSL} !=1 [NC] | |
RewriteRule ^(.*) https://www.pupi-boy.ru/$1 [L,R=301] | |
</IfModule> | |
Вариант 4 (При возникновении циклической переадресации) | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{HTTPS} off | |
RewriteCond %{HTTP:X-Forwarded-Proto} !https | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
</IfModule> | |
WordPress спешл, вставьте перед правилами WordPress | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)\ HTTP/ [NC] | |
RewriteCond %{HTTPS} off [NC] | |
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI}%{QUERY_STRING} [R=301,QSA,L] | |
</IfModule> | |
Редирект всех страниц кроме одной | |
Рекомендую не перенаправлять файл robots.txt | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{HTTPS} =off | |
RewriteCond %{REQUEST_URI} !^/robots.txt | |
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment