除了某些URI之外,从https重定向到http [英] Redirecting from https to http with the exception of some URI's
问题描述
所以我目前遇到的问题是我们整个网站都使用https编制索引。我们想使用.htaccess重定向到http。问题是我们需要一些URI仍然使用https,我不知道如何编写URI的例外
So the problem I am currently having is that our entire website is indexed using https. we want to redirect to http using .htaccess. the problem is that we need a couple of URIs to still use https and I am not sure how to write the exception for URIs
我知道下面的例子如果我们的网站功能如下www.example.com/account.php但我们的网站网址如www.example.com/index.php?l=account
I know the below example would work if our site functioned like this www.example.com/account.php but our site urls are like www.example.com/index.php?l=account
# Turn SSL on for account
RewriteCond %{HTTPS} off
RewriteCond %{SCRIPT_FILENAME} \/account\.php [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
如何我可以解决这个问题,任何指导都将不胜感激。
how can i fix this, any guidance would be appreciated.
谢谢
编辑!
所以下面的代码我已经工作但是我想再做一个例外,我似乎无法开始工作,我也希望root(index.php)只使用http。
So this code below I have working but I would like to make one more exception that I cant seem to get to work, I also want the root (index.php) to only use http.
我尝试使用...
RewriteCond %{REQUEST_URI} !^/index.php
但这不起作用
# invoke rewrite engine
RewriteEngine On
RewriteBase /
RewriteCond %{https} off
RewriteCond %{QUERY_STRING} !^l=product_detail
RewriteCond %{QUERY_STRING} !^l=product_list
RewriteCond %{QUERY_STRING} !^l=page_view
RewriteRule ^(.*)$ https://%{HTTP_HOST}/development/$1 [R=301,L]
谢谢
推荐答案
尝试
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/account.php
RewriteCond %{QUERY_STRING} !^l=account
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/account.php [OR]
RewriteCond %{QUERY_STRING} ^l=account
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
这篇关于除了某些URI之外,从https重定向到http的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!