很抱歉,当谈到regex时,我有点头脑不清醒,我尝试过,但失败了。
你能告诉我如何使索引/主页不在ssl中吗?现在我有一个重写规则,它强制整个站点使用ssl:
# force ssl
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
我需要的是主页/索引页不在ssl中。
尝试:
<IfModule mod_rewrite.c>
RewriteEngine on
# force ssl
RewriteCond %{REQUEST_URI} !^$ # no ssl on /
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}' /index'.php' HTTP/ # no ssl on index.php
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
正确的条件是:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
确保重写引擎已加载。
您需要另一个RewriteCond
。
RewriteCond %{REQUEST_URI} !^$