Apache Htaccess:使用https://www. 例外
我想将我网站中的每个请求重定向到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不能是强制性的。它们应该同时在http和https上工作。 这是我目前的访问权限: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
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
之前的第一个