-
Multiple rewriterules
I've been playing with this for the last 2 hours with no success! Really hoping sitepoint members can help!
As one normally does, we have rewrite running fine:
Code:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
However, what I want to do as well, is when a particular script is accessed, to rewrite it back to the rewritten format above.
For example:
Code:
RewriteEngine on
RewriteRule ^/somefolder/somescript.php(.*)$ index.php/$1 [L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
So if somefolder/somescript.php exists, translate the arguments to index.php like the other statement does. However, this doesn't seem to work.. Can anyone tell me what I'm doing wrong.. thank you.
-
akb,
First, WELCOME to SitePoint's Apache Forum.
Okay, back to WHAT rewritten format? No matter, what it looks like you're trying to do is to capture a query string with a RewriteRule. Since that cannot be done, you've got a problem. The answer is to capture the query string with a Rewrite Cond examining the %{QUERY_STRING} variable.
Finally, even that is not necessary as the QSA (Query String Appended) flag is designed to do that for you (if you create a new query string) - otherwise, it gets sent to the redirection script naturally.
Since you're not using query strings, however, you should take a look at the Options -MultiViews setting as most servers are set to NOT let you use a filename in place of a directory in a URI path.
Regards,
DK