1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > php 重定向到https php - 如何从HTTPS重定向到HTTP? - SO中文参考 - www.soinside.com

php 重定向到https php - 如何从HTTPS重定向到HTTP? - SO中文参考 - www.soinside.com

时间:2019-07-08 17:49:59

相关推荐

php 重定向到https php - 如何从HTTPS重定向到HTTP? - SO中文参考 - www.soinside.com

如果我了解您,以下代码将解决此问题:

RewriteEngine On

RewriteCond %{HTTPS} =off

RewriteCond %{SCRIPT_FILENAME} !\/index\.php [NC]

#the above line will exclude /index.php

# from the following rules

RewriteCond %{SCRIPT_FILENAME} !\/dealers\.php [NC]

# the above line will exclude the /dealers.php

# from the following rules

RewriteRule (.+) https://%{HTTP_HOST}/$1 [L,R=301]

# above line will force every pages and directories ,except those who

# excluded above and the main root , to redirect from http to https

# (.+) means not to consider / and if you

# change it by (.*) it will be considered

现在,您可以强制将整个网站从http重定向到https,但和/dealers除外。

注意:在测试上述代码之前,请确保您清空浏览器缓存

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。