如何从HTTPS重定向到HTTP? [英] How to redirect from HTTPS to HTTP?
问题描述
- 主页 - www.hellomysite.com
- 经销商页面-www.hellomysite.com/dealers
即使用户输入了 https://www.hellomysite.com/dealers ,它应该通过HTTP提供。 http://www.hellomysite.com/dealers
我去谷歌找到的链接数,但没有一个被重定向。
.htaccess
#Redirect所有请求到HTTPS
RewriteCond%{HTTPS}关闭[OR]
RewriteCond%{HTTP_HOST} ^ www.hellomysite\.com *
RewriteRule ^(。*)$ https://hellomysite.com/$1 [L,R = 301]
#RewriteCond%{HTTPS} on [OR]
#RewriteRule ^ https:// hellomysite .com / dealers $ http:// hellomysite / dealers [R = 301,L,QSA]
如果我再尝试一下,那么在打开网站时收到一个错误。
这个网站有太多重定向
如何重定向主页和经销商页面到HTTP。
如果我明白以下代码将解决它:
RewriteEngine On
RewriteCond%{HTTPS} = off
RewriteCond%{SCRIPT_FILENAME}!\ / index\。 php [NC]
#以上行将从以下规则中排除https://www.hellomysite.com/index.php
#
RewriteCond%{SCRIPT_FILENAME}! \ / dealers\.php [NC]
#以上行将从以下规则中排除https://www.hellomysite.com/dealers.php
#
RewriteRule(。+)https://%{HTTP_HOST} / $ 1 [L,R = 301]
#above line将强制每个页面和目录,除了上面排除
#主根,从http重定向到https
#(。+)意味着不要考虑http://www.hellomysite.com/,如果
#更改它(。*)将会认为
现在您可以强制整个网站从http重定向到https e x32 www.hellomysite.com和www.hellomysite.com/dealers。
注意:请确保在上述测试之前清空浏览器缓存代码
I have a Website. Where I need to redirect all the pages from HTTP to HTTPS. But there are two page which should not served over HTTPS.
- Home Page - www.hellomysite.com
- Dealers Page -www.hellomysite.com/dealers
Even if user has entered the url as https://www.hellomysite.com/dealers, it should be served over HTTP. http://www.hellomysite.com/dealers
I googled & found number of links but none of them is redirected.
.htaccess
#Redirect all request to HTTPS
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.hellomysite\.com*
RewriteRule ^(.*)$ https://hellomysite.com/$1 [L,R=301]
#RewriteCond %{HTTPS} on [OR]
#RewriteRule ^https://hellomysite.com/dealers$ http://hellomysite/dealers [R=301,L,QSA]
If I try anything more, then I get an error on opening the site as
This website has too many redirects
How do I redirect Home Page & the dealers page to HTTP.
If i understand you the following code will solve it :
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
Now you can force entire web site to redirect from http to https except www.hellomysite.com and www.hellomysite.com/dealers.
Note : please make sure that you empty browser cache before testing above code
这篇关于如何从HTTPS重定向到HTTP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!