.htaccess :如何在URL匹配时绕过所有规则



我有一个.htaccess文件:

SetEnv PHP_VER 5_TEST
RewriteEngine On
#RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !/pay|ok|ko|retour/ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^(blog|www|flashgames).sample.com$
RewriteRule ^(.*) http://www.sample.com/$1 [QSA,L,R=301]
ErrorDocument 404 https://www.sample.com/index.php

我想在乞丐处添加该规则

当 url 为 : 时 http://www.sample.com/test.php 然后返回(什么都不做(,只需绕过所有规则。

知道吗?

您可以使用破折号-代替RewriteRule

- (破折号(
破折号表示不应执行替换(现有路径原封不动地传递(。当需要在不更改路径的情况下应用标志(见下文(时,将使用此方法。

使用 L |last 标志,它将跳过所有以下规则。这意味着,当您在开头插入规则时

RewriteRule ^test.php$ - [L]

它只会处理test.php,就好像根本没有规则一样。

当您在中间的某个位置插入此规则时,Apache 将处理到目前为止的所有规则,然后退出规则链。

相关内容

最新更新