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 https://www.hellomysite.com/index.php
# from the following rules
RewriteCond %{SCRIPT_FILENAME} !\/dealers\.php [NC]
# the above line will exclude the https://www.hellomysite.com/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 http://www.hellomysite.com/ and if you
# change it by (.*) it will be considered
現在,您可以強制將整個網站從http重定向到https,但www.hellomysite.com和www.hellomysite.com/dealers除外。
注意:在測試上述代碼之前,請確保您清空瀏覽器緩存
總結
以上是生活随笔為你收集整理的php 重定向到https,php - 如何从HTTPS重定向到HTTP? - SO中文参考 - www.soinside.com的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: struts.xml 属性介绍
- 下一篇: 用axure绘制PHP工作流程图,如何用