[PHP] Re: mod_rewrite (the solution)

2002-04-17 Thread CC Zona

In article [EMAIL PROTECTED], [EMAIL PROTECTED] 
wrote:

 RewriteEngine  on
 RewriteBase/
 RewriteRule$.* index.php

RewriteRule takes a regular expression as its first parameter 
http://httpd.apache.org/docs/mod/mod_rewrite.html#RewriteRule.

The $ regex meta-character is an end-of-line marker.  It has no special 
meaning at the beginning of a pattern.  If you want a pattern that matches 
anything including nothing, use:

RewriteRule ^.*$ index.php

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: mod_rewrite (the solution)

2002-04-17 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Cc Zona) wrote:

 In article [EMAIL PROTECTED], [EMAIL PROTECTED] 
 wrote:
 
  RewriteEngine  on
  RewriteBase/
  RewriteRule$.* index.php
 
 RewriteRule takes a regular expression as its first parameter 
 http://httpd.apache.org/docs/mod/mod_rewrite.html#RewriteRule.
 
 The $ regex meta-character is an end-of-line marker.  It has no special 
 meaning at the beginning of a pattern.  If you want a pattern that matches 
 anything including nothing, use:
 
 RewriteRule ^.*$ index.php

I shouldn't have copy/pasted, because index.php also is wrong in this 
context.  If one is trying to redirect from, say, 
/dir_that_may_not_exist/ to index.php, then how is apache supposed to 
serve up /dir_that_may_not_exist/index.php.  It can't.  So logically the 
2nd parameter has to be /index.php.  For clarity's sake, using the L 
modifier for parameter #3 is also a good idea:

RewriteRule ^.*$ /index.php [L]

Mod_rewrite is a complex beast, so read the docs closely.  And if all you 
really need is to capture/redirect 404s, check out the ErrorDocument 
directive instead.  Simple to use, easy to learn, and none of the 
mod_rewrite overhead.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php