Hypothetical situation: I've got a PHP script:
/dostuff.php
It takes a parameter "thing":
/dostuff.php?thing=monster
But I'm using mod_rewrite to make it look better, so the URL I want users to see (and use) is:
/dostuff/monster
For this purpose I've created a simple rewrite rule:
RewriteRule ^dostuff/(.*)$ dostuff.php?thing=$1
However, I then would like to prevent users from accessing the original script with "dostuff.php" - I want that to hit a 404 (or 403). I tried doing this:
RewriteRule ^.*\.php nonexistentpage
RewriteRule ^dostuff/(.*)$ dostuff.php?thing=$1
But for some reason, this blocks all access to the script, even when using the "dostuff/" version. I don't understand why that occurs - does Apache loop through the RewriteRules multiple times? If the URL doesn't include ".php" until after the second rule, why would the first rule end up being applied?
/dostuff.php
It takes a parameter "thing":
/dostuff.php?thing=monster
But I'm using mod_rewrite to make it look better, so the URL I want users to see (and use) is:
/dostuff/monster
For this purpose I've created a simple rewrite rule:
RewriteRule ^dostuff/(.*)$ dostuff.php?thing=$1
However, I then would like to prevent users from accessing the original script with "dostuff.php" - I want that to hit a 404 (or 403). I tried doing this:
RewriteRule ^.*\.php nonexistentpage
RewriteRule ^dostuff/(.*)$ dostuff.php?thing=$1
But for some reason, this blocks all access to the script, even when using the "dostuff/" version. I don't understand why that occurs - does Apache loop through the RewriteRules multiple times? If the URL doesn't include ".php" until after the second rule, why would the first rule end up being applied?