【发布时间】:2025-11-23 01:05:01
【问题描述】:
我正在尝试重定向:
http://website.com & http://website.com/index.php 到 https://website.com
我找到的所有解决方案都会将http://website.com/test.php(已登录)重定向到 401 页面。我只想 / 和 /index.php 重定向到 HTTPS
以下代码不能满足我的需要:
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]
【问题讨论】: