Przekierowanie strony z http na https

w pliku .htaccess na serwerze wprowadzamy kod:


<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTPS} =off [OR]
RewriteCond %{HTTP_HOST} !^mypage\.pl$
RewriteRule ^(.*)$ "https://mypage.pl/$1" [R=301,L]
</IfModule>

do daje:

http://www.mypage.pl/ – https://mypage.pl/
http://www.mypage.pl/cos – https://mypage.pl/cos
https://www.mypage.pl/ – https://mypage.pl/
https://www.mypage.pl/cos – https://mypage.pl/cos

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#https