A pre-defined URL re-write

I know there are lots of mod re-write out there for friendly SEO URL, but I can’t seem to find how to make my work
Basically I want to re-write the URL for my website in this format;



As you can see it will have a pre-defined URL to re-write to.

Please your help would be highly appreciated.


What you’re asking is a bit broad in scope.

If you have something like

RewriteRule ^(.*)$ index.php?q=$1

Then within index.php - it has to parse $_GET[‘q’] and send it off to the appropriate handler.

At the minimum, you could hard code “productlist” like this:

RewriteRule ^productlist(.*)$ productlist.php?cat=$1

Then change productlist.php to accept $_GET[‘cat’] as a string, which would require a minor change to a DB query. But hard coding each request is a bad idea, the proper way is to build a controller that handles all request (productlist/foo-bar) and sends it off to the appropriate handler (productlist.php) dynamically.

There’s a lot more to mod_rewriting, it’s not just a superficial change to the URL as the PHP system needs to handle it differently. A well designed system will be able to handle both non rewritten as well as written URLs, however with the way your’s is set up, it requires some recoding.

Also I have no idea the depth of your site so how much/little change is required is unknown.