Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache Htaccess:使用https://www. 例外_Apache_.htaccess - Fatal编程技术网

Apache Htaccess:使用https://www. 例外

Apache Htaccess:使用https://www. 例外,apache,.htaccess,Apache,.htaccess,我想将我网站中的每个请求重定向到https://www.并将所有内容隧道到index.php 类似URL有两个例外: http://www.example.com/share/AAAAA https://www.example.com/share/BBBBB 及 http://www.example.com/loader/AAAAA https://www.example.com/loader/BBBBB (AAAA和BBBB可以是任何东西) 对于这些URL,我希望它始终使用www,但是http

我想将我网站中的每个请求重定向到https://www.并将所有内容隧道到index.php

类似URL有两个例外:

http://www.example.com/share/AAAAA

https://www.example.com/share/BBBBB

http://www.example.com/loader/AAAAA

https://www.example.com/loader/BBBBB

(AAAA和BBBB可以是任何东西)

对于这些URL,我希望它始终使用www,但是https不能是强制性的。它们应该同时在httphttps上工作。 这是我目前的访问权限:

ErrorDocument 403 /403.php

RewriteEngine On

#USE HTTPS
RewriteCond %{REQUEST_URI} !^/(share/|loader/)
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L,QSA]

#ALWAYS USE www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?rest=$1 [L,QSA]
这适用于其余页面,例外情况除外。 如果我进去

http://www.example.com/share/AAAAA

在浏览器中,它将我重定向到

https://www.example.com/index.php?rest=share/AAAAA


因此,它不仅添加了https,而且还显示了url中的?rest内容。请注意?rest=问题并非发生在所有其他链接上。这应该在后台进行隧道挖掘。

使用
请求
而不是
请求URI
变量:

ErrorDocument 403 /403.php
RewriteEngine On

#USE HTTPS
RewriteCond %{THE_REQUEST} !\s/+(share/|loader/)
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

#ALWAYS USE www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=302]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?rest=$1 [L,QSA]

_REQUEST
变量表示Apache从浏览器收到的原始请求,在执行某些重写规则后不会被覆盖。此变量的示例值为
GET/index.php?id=123 HTTP/1.1

使用
请求
而不是
请求URI
变量:

ErrorDocument 403 /403.php
RewriteEngine On

#USE HTTPS
RewriteCond %{THE_REQUEST} !\s/+(share/|loader/)
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

#ALWAYS USE www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=302]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?rest=$1 [L,QSA]

_REQUEST
变量表示Apache从浏览器收到的原始请求,在执行某些重写规则后不会被覆盖。这个变量的示例值是
GET/index.php?id=123 HTTP/1.1

,非常感谢!你能解释一下这个词的意思吗\s/+规则?这实际上是一个否定。通过放置
\s/+
GET
之后的一部分,即空格和
/
之前的第一个
/
在URL中的
共享
非常感谢!你能解释一下这个词的意思吗\s/+规则?这实际上是一个否定。通过放置
\s/+
GET
之后的一部分,即空格和URL中
share
之前的第一个