我想强制将对我网站的任何访问重定向到https。 我的htaccess规则如下:
# rewrite address
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mytestsite\.eu$ [NC]
RewriteRule ^(.*)$ https://www.mytestsite.eu/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ https://www.mytestsite.eu/$1 [R=301,L]
#RewriteCond %{HTTP_HOST} ^(.+)\.mytestsite\.eu$ [NC]
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^ https://www.mytestsite.eu/ [L,R]
我该怎么做到这一点?
像这样重写前三行:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]