根据我的值IS_HTTP,我决定在下面的代码之后,URL是否应该是https或http。htaccess从重写文件中排除1个文件夹
我希望总是http(从https重定向)为http://mydomain.com
(具有空的QUERY_STRING),http://mydomain.com/?q=home
,http://mydomain.com/?qq=home
。 下面的代码可以很好地适用于这样的URL,它将IS_HTTP设置为1.一切都很完美。但我也想要管理文件夹的URL总是httpS,所以我想从这个块中排除这样的URL。
这就是为什么我将第二个字符串添加到下面的代码,但它不会阻止此类URL应用RewriteRule^- [E=IS_HTTP:1]
。为什么?
#determine if page is supposed to be http
RewriteCond %{REQUEST_URI} !^administration [NC]
#if it has q=home or qq=home in querystring
RewriteCond %{QUERY_STRING} (^|&)(q=home|qq=home)(&|$) [NC,OR]
#or if query string is empty
RewriteCond %{QUERY_STRING} ^$
#set env var to 1
RewriteRule^- [E=IS_HTTP:1]
同样,我想https://mydomain.com/administration/index.php
和为什么上面的代码不会阻止他们被RewriteRule^- [E=IS_HTTP:1]
之前停止从文件夹/管理的所有其他文件?
我已经试过第二个字符串是:
RewriteCond %{REQUEST_URI} !^administration [NC]
RewriteCond %{REQUEST_URI} !^/administration [NC]
但他们没有工作。 (我相信/这里不需要,因为REQUEST_URI不是从/开始的,但我可能是错的)。
谢谢。