.htaccess 如何从http重定向到https,但如果htaccess中的index.php文件没有重定向
我在htaccess中使用此代码从http重定向到https。我不想要index.php文件重定向.htaccess 如何从http重定向到https,但如果htaccess中的index.php文件没有重定向,.htaccess,redirect,.htaccess,Redirect,我在htaccess中使用此代码从http重定向到https。我不想要index.php文件重定向 RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] 我怎么能做到 您可以在重写规则中调整您的模式: RewriteCond %{HTTPS} off RewriteRule !^(index\.php)?$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
我怎么能做到 您可以在
重写规则中调整您的模式:
RewriteCond %{HTTPS} off
RewriteRule !^(index\.php)?$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L,NC]
^(index\.php)$
将匹配除登录页和index.php
内部服务器错误以外的任何内容。不起作用。我从你的答案中复制这个代码并粘贴。谢谢。现在它的工作很好。但我只需要example.php文件。但是登录页必须重定向到httpssory,我不明白你对example.php
的评论。这个答案是根据您的问题的要求,除了index.php
之外,它重定向http->https
另一个问题:将所有登录页重定向到https,而不是file example.php。然后它将是:RewriteRule^示例\.php$https://%{SERVER_NAME}%{REQUEST_URI}[R=301,L,NC]