Simple rewrite question

Discussion in 'Apache' started by SecureCP, Jan 6, 2011.

  1. #1
    Hello, I'm working on a project and this is the first time I've gotten into rewriting URLs. Currently I have the following in my .htaccess:
    
    RewriteEngine on
    RewriteRule ^cleveland$ index.php?category_id=1
    RewriteRule ^pittsburgh$ index.php?category_id=2
    RewriteRule ^youngstown$ index.php?category_id=3
    
    Code (markup):
    This is working good, and it does what it should. The new dilemma is, how can I post an additional variable on to this. I have a variable which would come out to index?category_id=1&sex=m so do I just add the following below the above entries?
    
    RewriteRule ^pittsburgh/men$ index.php?category_id=2&sex=m
    RewriteRule ^pittsburgh/women$ index.php?category_id=2&sex=f
    
    Code (markup):
    This seems a bit redundant and I believe there's a better way which is why I'm asking for the gurus' help. :)

    Any help is greatly appreciated!
     
    SecureCP, Jan 6, 2011 IP