New to rewrites, I'm pretty sure I'm doing it wrong.

Discussion in 'Apache' started by SecureCP, Mar 25, 2011.

  1. #1
    Hi everyone, I'm fairly new to rewrites. I've managed to cut down urls to more seo friendly ones with the following (domain.com/city_name)
    
    RewriteEngine on
    RewriteRule ^cleveland$ index.php?category_id=1&%{QUERY_STRING}
    RewriteRule ^pittsburgh$ index.php?category_id=2&%{QUERY_STRING}
    RewriteRule ^youngstown$ index.php?category_id=3&%{QUERY_STRING}
    RewriteRule ^rustyoriginals$ index.php?category_id=4&%{QUERY_STRING}
    RewriteRule ^sale$ index.php?sale=1
    
    Code (markup):
    Now my problem lies here, I'm trying to go a bit deeper (keep in mind the above will never change because these are the only categories there will ever be). I want to switch to domain.com/city_name/shirt_name; however, to view a shirt I need to route through a page called shirt.php where it accepts variables such as shirt_id=.

    Can anyone please point me in the right direction? I've read a few articles and I'm not finding any examples or theory which could help me.

    Thanks!
     
    SecureCP, Mar 25, 2011 IP