httpd-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Httpd Wiki] Update of "RewriteCond" by sjorge
Date Fri, 11 Mar 2011 12:54:12 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.

The "RewriteCond" page has been changed by sjorge.
http://wiki.apache.org/httpd/RewriteCond?action=diff&rev1=2&rev2=3

--------------------------------------------------

  The '''RewriteCond''' directive defines conditions under which the rewriting should take
place.
  
  == Syntax ==
- 
  We should really encourage people to use the lexicographically equal operator instead of
a RegEx if they want to ckeck, if ''test string'' is lexicographically equal to ''cond pattern''.
  
- E.g. using 
+ E.g. using
+ 
  {{{
- RewriteCond {HTTP_HOST} !=""
+ RewriteCond %{HTTP_HOST} !=""
+ }}}
- }}} instead of
+ instead of
+ 
  {{{
- RewriteCond {HTTP_HOST} .
+ RewriteCond %{HTTP_HOST} .
  # or
- RewriteCond {HTTP_HOST} !^$
+ RewriteCond %{HTTP_HOST} !^$
- }}} or using
+ }}}
- {{{RewriteCond {REQUEST_URI} !=/foo/bar
+ or using{{{RewriteCond {REQUEST_URI} !=/foo/bar }}} instead of
- }}} instead of
+ 
  {{{
- RewriteCond {REQUEST_URI} !^/foo/bar$
+ RewriteCond %{REQUEST_URI} !^/foo/bar$
  }}}
- or
- {{{RewriteCond {SERVER_PORT} =443
+ or {{{RewriteCond {SERVER_PORT} =443 }}} instead of
- }}} instead of
+ 
  {{{
- RewriteCond {SERVER_PORT} ^443$
+ RewriteCond %{SERVER_PORT} ^443$
  }}}
+ '''Note:''' Conditions are being processed after the pattern of the RewriteRule has matched.
This means that the Condition in following example would be useless (it's always true):
  
- '''Note:''' Conditions are being processed after the pattern of the RewriteRule has matched.
This means that the Condition in following example would be useless (it's always true):
  {{{
  RewriteCond %{REQUEST_URI} \.html$
  RewriteRule \.html$ - [G]
  }}}
+ While this one wastes performance:
  
- While this one wastes performance:
  {{{
  RewriteCond %{REQUEST_URI} ^/([^.]*)\.html$
  RewriteRule ^/(.*) /%1.php [PT]
  }}}
  Every Request matches the rule-pattern and after that the condition will be checked. But
you can easily check the uri value in the rule-pattern, so that there is no need for such
a condition here:
+ 
  {{{
  RewriteRule ^/([^.]*)\.html$ /$1.php [PT]
  }}}
- 
  == Examples ==
  See ConditionalRewrites
  

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org


Mime
View raw message