Re: mod_rewrite (the solution)

From: Date: Wed, 17 Apr 2002 23:56:57 +0000
Subject: Re: mod_rewrite (the solution)
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-93445@lists.php.net to get a copy of this message
In article <email-BA5573.16150517042002@pb1.pair.com>, email@cczona.com (Cc Zona) wrote: > In article <LAW2-F53U3AfCWPM9Bv0000150e@hotmail.com>, rswfire@hotmail.com > 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

« previous php.general (#93445) next »