"OR" Flag in .htaccess mod_rewrite

gabriel-kaam picture gabriel-kaam · Sep 18, 2012 · Viewed 51.8k times · Source

Just found this .htaccess rewrite code

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.

Any ideas?

Answer

waraker picture waraker · Sep 18, 2012

from 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:

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