我正在尝试重定向:
http://website.com & http://website.com/index.php 到 https://website.com
我找到的所有解决方案都将重定向 http://website.com/test.php
以下代码不适合我的需要:
RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
你可以用这条规则作为你的规则 最高准则 :
RewriteEngine On RewriteCond %{HTTPS} !on [OR] RewriteCond %{REQUEST_URI} ^/index\.php$ [NC] RewriteRule ^(?:index\.php)?$ https://%{HTTP_HOST} [L,NE,R=301]
确保这是最重要的规则,并从新浏览器进行测试。