I using htaccess mod_rewrite for a product site.
when a product is going to be add,
I create a hierarchy of product categories in url
like
1) http://www.example.com/Place-an-ad/Cars/Mazda/mazda-y/mazda-y-2/ 4 levels here 2) http://www.example.com/Place-an-ad/Books/Science/ 2 levels here 3) http://www.example.com/Place-an-ad/Realestate/Apprtments/small/ 3 levels here
categories can be 2, 3 or 4 level
I put this in htaccess, eventhough I do not want to duplicate.
RewriteRule ^Place-an-ad/(.*)/(.*)/(.*)/(.*)/(.*)/?$ new_ad.php?c1=$1&c2=$2&c3=$3&c4=$4 [NC,L] # for 4 level categories
RewriteRule ^Place-an-ad/(.*)/(.*)/(.*)/(.*)/?$ new_ad.php?c1=$1&c2=$2&c3=$3 [NC,L] # for 3 level categories
RewriteRule ^Place-an-ad/(.*)/(.*)/(.*)/?$ new_ad.php?c1=$1&c2=$2 [NC,L] # for 2 level categories
RewriteRule ^Place-an-ad/(.*)/(.*)/?$ new_ad.php?c1=$1 [NC,L] # for 1 level category
Can any one short this, so that all categories can be handled by one rule.
It would be much easier to do this sort of url rewriting using whichever server side language (e.g. PHP) your site is written in. If you have these urls stored in a database you can add a table column to store the name of the script that should be executed when each url is called.