#1
  1. if(x!="code"){die;
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    wheeling, wv
    Posts
    47
    Rep Power
    11

    REGEX help on url redirection with mod_rewrite


    hey all,

    im using an .htaccess file on my server to do url redirection. basically im hiding php server variables from the user w/ a mod_rewite trick. the code i have "works" but not quite the way i want it...

    Code:
    RewriteEngine on
    RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ info.php?x=$1&y=$2&z=$3
    RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ info.php?x=$1&y=$2&z=$3
    so, if you enter this url:

    http://www.mysite.com/xero/owns/us

    that will display the content from

    http://www.mysite.com/info.php?x=xero&y=owns&x=us

    which is want i want it to do.
    but, i want those 3 variables to be OPTIONAL!
    so, if your typed in just /xero/owns it would do mysite.com/info.php?x=xero&y=owns&z= (null)

    can any one point me in the right direction?

    thanx!

    -----------------[EDIT]------------------

    i should have posted this in the apache forum.

    also, i found the answer on this sticky

    sorry!
    Last edited by ph33r; September 24th, 2008 at 09:04 AM.
    +============+
    | http://xero.nu |
    +============+

IMN logo majestic logo threadwatch logo seochat tools logo