我的网站上有htaccess两个问题
http://example.com => https://www.example.com
我的.htaccess:
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
它适用于所有浏览器,除非我尝试在Mozilla Firefox上访问example.com,并重写为https://www.example.com/https://example.com/
我的网站支持通配符子域,因此我不会重写所有子域。
答案 0 :(得分:1)
我想这就是你要找的东西:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(example\.com)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
我不知道你提到的那个mozilla异常。可能是一个缓存问题?您需要仔细查看日志文件,也许您必须启用重写日志记录才能看到重写引擎内部究竟发生了什么......