.htaccess mod_rewrite中的“OR”标志

时间:2022-10-06 10:32:50

Just found this .htaccess rewrite code

刚发现这个.htaccess重写代码

RewriteEngine on
RewriteCond %{HTTP_HOST} ^my.domain.com$ [NC,OR]
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]

And I was wondering what was the purpose of the "OR" flag. Already checked the doc http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriteflags but coulnd find any infos.

我想知道“OR”标志的目的是什么。已经检查了文档http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriteflags但是可以找到任何信息。

Any ideas?

有任何想法吗?

1 个解决方案

#1


42  

from http://httpd.apache.org/docs/current/mod/mod_rewrite.html

来自http://httpd.apache.org/docs/current/mod/mod_rewrite.html

ornext|OR (or next condition) Use this to combine rule conditions with a local OR instead of the implicit AND. Typical example:

ornext | OR(或下一个条件)使用此命令将规则条件与本地OR组合而不是隐式AND。典型例子:

RewriteCond %{REMOTE_HOST}  ^host1  [OR]
RewriteCond %{REMOTE_HOST}  ^host2  [OR]
RewriteCond %{REMOTE_HOST}  ^host3
RewriteRule ...some special stuff for any of these hosts...

#1


42  

from http://httpd.apache.org/docs/current/mod/mod_rewrite.html

来自http://httpd.apache.org/docs/current/mod/mod_rewrite.html

ornext|OR (or next condition) Use this to combine rule conditions with a local OR instead of the implicit AND. Typical example:

ornext | OR(或下一个条件)使用此命令将规则条件与本地OR组合而不是隐式AND。典型例子:

RewriteCond %{REMOTE_HOST}  ^host1  [OR]
RewriteCond %{REMOTE_HOST}  ^host2  [OR]
RewriteCond %{REMOTE_HOST}  ^host3
RewriteRule ...some special stuff for any of these hosts...