.htaccess Htaccess重定向/和index.php到HTTPS

.htaccess Htaccess重定向/和index.php到HTTPS,.htaccess,redirect,https,.htaccess,Redirect,Https,我正在尝试重定向: &到 我找到的所有解决方案都将重定向(已登录)到401页面。我只想/and/index.php重定向到HTTPS 以下代码不适用于我的需要: RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 及 您可以将此规则用作最顶层的规则: RewriteEngine On RewriteCond %{HTTPS} !on [O

我正在尝试重定向:

&到

我找到的所有解决方案都将重定向(已登录)到401页面。我只想/and/index.php重定向到HTTPS

以下代码不适用于我的需要:

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


您可以将此规则用作最顶层的规则:

RewriteEngine On

RewriteCond %{HTTPS} !on [OR]
RewriteCond %{REQUEST_URI} ^/index\.php$ [NC]
RewriteRule ^(?:index\.php)?$ https://%{HTTP_HOST} [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]