I am fairly new to mod_rewrite and I have read numerous tutorials, my apache manual, and dklynn’s page. I must be misunderstanding some of the specs and misapplying them.
I am just experimenting with my mvc sandbox site on my local machine and want to rewrite all URIs to be in a single GET variable:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mod.*$ index.php?rt=test [L]
RewriteRule ^(.*)$ index.php?rt=$1
If the URI begins with “mod,” redirect to the root controller with “test” as the value of the rt GET variable. Otherwise, use the entire URI into the value of the rt GET variable. This does not work as expected. I am logging the entire value of the GET array to check. //mysite/mod sends a value of “index.php” with the rt variable, when it should be sending “test.” So, in testing, I commented out the second RewriteRule and the redirection worked as expected. Therefore I figured that I should add the L(ast) flag to stop processing after the first rule. I uncommented the second rule and tried again and, once again, “index.php” was sent with rt. I don’t understand what I am doing wrong. Anyone have any insight?