0

http://httpd.apache.org/docs/2.2/rewrite/intro.html言います:

mod_rewrite では、!文字を正規表現の前に使用して、それを否定できます。つまり、文字列は、式の残りの部分と一致しない場合にのみ一致したと見なされます。

ただし、私の構成は最初のルールでのみ機能し、2 番目のルールでは機能しません。誰かが理由を教えてもらえますか?

RewriteCond %{HTTP_HOST} !^static\.example\.com
RewriteCond %{HTTP_HOST} ^host\.example\.com
RewriteRule ^(/global/.*)$ /dir1
RewriteRule !^(/global/.*)$ /dir2    #this rule doesn't work.
4

1 に答える 1

0

実際、ルールを2つに分割することで、これを機能させることができます。host.example.comとexample.comはどちらも正常に機能します。

RewriteCond %{HTTP_HOST} !^static\.example\.com
RewriteCond %{HTTP_HOST} ^host\.example\.com
RewriteRule ^(/global/.*)$ /dir1 [L]

RewriteCond %{HTTP_HOST} !^static\.example\.com
RewriteCond %{HTTP_HOST} ^host\.example\.com
RewriteRule ^(.*)$ /dir2 [L]

ただし、「!」の使い方を知りたいのですが。RewriteRuleで。

于 2012-06-28T18:02:59.903 に答える