【发布时间】:2020-11-16 15:27:27
【问题描述】:
我有一个非 WWW 域,当我尝试设置重定向到 HTTPS 时,从 http://www.examle.com 重定向到 https://www.example.com 对我有效,但 http://example.com 不适用于 https://example.com。当前的htaccess是:
RewriteEngine On
RewriteCond %{REQUEST_URI} .*index\.html/?$ [NC]
RewriteRule ^(.*)index\.html/?$ https://$1 [R=301,L,NC]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
RewriteCond $1 !index\.php
RewriteCond $1 !^assets
RewriteCond $1 !^robots.txt
RewriteCond $1 !^sitemap.xml
RewriteRule ^(.*)$ index.php [L]
你能告诉我我做错了什么吗?谢谢
更新:
当前.htaccess
RewriteEngine On
RewriteCond %{REQUEST_SCHEME} =http
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
RewriteCond %{REQUEST_URI} .*index\.html/?$ [NC]
RewriteRule ^(.*)index\.html/?$ https://$1 [R=301,L,NC]
RewriteCond $1 !index\.php
RewriteCond $1 !^assets
RewriteCond $1 !^robots.txt
RewriteCond $1 !^sitemap.xml
RewriteRule ^(.*)$ index.php [L]
【问题讨论】: