If your mod_rewrite has a rule like the following:
RewriteRule ^hello/world /?action=hello&sub=world [NC,L]
or, the more generalised:
// Assuming only lowercase letters in action & sub..
RewriteRule ^([a-z]+)/([a-z]+) /?action=$1&sub=$2 [NC,L]
then the same PHP script is being called, with the $_REQUEST
variables available whichever way the user accesses the page (dirty or clean url).
We recently moved a large part of our site to clean urls (still supporting the older, "dirty" urls) and rules like the above meant we didn't have to rewrite any code that relied on $_REQUEST
params, only the mod_rewrite rules.
Update
Mod_rewrite is an Apache module, but there are a number of options available for IIS also.
Whichever web server you decide to support, the mod_rewrite approach will likely result in the least amount of work for you. Without it, you'd likely have to create a load of files to mimic the structure of your clean urls, e.g. in your webserver root you'd create a directory hello
, placing a file world
into it, containing something like the following:
// Set the $_REQUEST params to mimic dirty url
$_REQUEST['action'] = 'hello';
$_REQUEST['sub'] = 'world';
// Include existing file so we don't need to re-do our logic
// (assuming index.php at web root)
include('../index.php');
As the number of parameters you wish to handle 'cleanly' increases, so will the number of directories and stub files you require, which will greatly increase your maintenance burden.
mod_rewrite is designed for exactly this sort of problem, and is now supported on IIS as well as Apache, so I'd strongly recommend going in that direction!