如果在htaccess中的index.php文件,如何从http重定向到https但没有重定向

时间:2015-10-14 10:49:30

标签: .htaccess redirect

我在htaccess中使用此代码从http重定向到https。如果index.php文件

,我不需要重定向
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

我怎么能这样做。

1 个答案:

答案 0 :(得分:1)

你可以在RewriteRule中调整你的模式:

RewriteCond %{HTTPS} off
RewriteRule !^(index\.php)?$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L,NC]
除了着陆页和^(index\.php)?$之外,

index.php将匹配任何内容。