Multiple rewrite conditions???

Discussion in 'Apache' started by jdblewitt1, Nov 21, 2011.

  1. #1
    I have a folder babysitters on my root with an index.php file and an .htaccess file

    Here is the current .htaccess file that was written for me previously

    Code:

    RewriteEngine on
    RewriteBase /babysitters
    RewriteRule ^(.*)$ index.php?city=$1 [QSA,L]

    I assume as it is now, /babysitters/pittsburgh is rewritten to /babysitters/index.php?city=pittsburgh

    I want to modify this so that /babysitters/pa equals

    /babysitters/index.php?state=pa

    and /babysitters/pa/pittsburgh equals

    /babysitters/index.php?state=pa&city=pittsburgh

    and /babysitters/pa/pittsburgh/15239 equals

    /babysitters/index.php?state=pa&city=pittsburgh&zip=15239

    Can I have all these in one htaccess file? I need it so that the url can be as short as /babysitters/state up to /babysitters/state/city/zip and the appropriate variables will be defined.

    My index page is coded to react differently depending on what variables are defined. I don't know anything about this stuff and don't really have a programming background, so trying to research this has led to several unsuccessful hours. Any help would be great
     
    jdblewitt1, Nov 21, 2011 IP