【发布时间】:2019-04-30 09:40:20
【问题描述】:
我想了解我的错误在哪里。我的 .htaccess 有问题,我想将所有基本条目重定向到 https://www.example.com。
http://example.com to https://www.example.com
http://www.example.com to https://www.example.com
https://example.com to https://www.example.com
http://example.com/index.html to https://www.example.com
http://www.example.com/index.html to https://www.example.com
https://example.com/index.html to https://www.example.com
一切都必须重定向到https://www.example.com,但目前它不起作用。我的错误在哪里,如何改进代码?
我的代码:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^/?$ "https\:\/\/www\.example\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC]
RewriteRule . http://www.%{HTTP_HOST}%1 [R=301,NE,L]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule . http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC]
RewriteRule . %1 [R=301,NE,L]
可能重复
也许我不明白,但对我来说 htaccess redirect to https://www 没有回答我的问题,因为它没有解决我问题的 /index.html 部分。
【问题讨论】:
-
如果我是对的,您提供的链接对 /index.html 部分不起作用
标签: .htaccess redirect mod-rewrite https