#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    8
    Rep Power
    0

    Help to understand regex in mod_rewrite - multiple parameter problem


    hello, i'm new in regex, currently i'm able to do simple regex in mod-rewrite for fix parameter. example for fix 3 parameter like:
    RewriteRule ^home/(.*)/(.*)/(.*)/(.*)\.html?$ index.php?mod=home&catID=$1&src=$2&p=$3 [L]

    but now i develop a page that has maximum of 3 parameter. So it could be 1 or 2 or 3 parameter. I create this kind of RewriteRule and failed:
    RewriteRule ^member/(.*)/(.*)\.html?$ index.php?mod=member&catID=$1 [L]
    RewriteRule ^member/(.*)/(.*)/(.*)\.html?$ index.php?mod=member&catID=$1&src=$2 [L]
    RewriteRule ^member/(.*)/(.*)/(.*)/(.*)\.html?$ index.php?mod=member&catID=$1&src=$2&p=$3 [L]

    anybody could give me a clue ? because it's not working right now
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    8
    Rep Power
    0
    found temporary solution with this rewrite rule:
    RewriteRule ^member/([-a-zA-Z0-9_]*)/[-a-zA-Z0-9_]*\.html$ index.php?mod=member&catID=$1 [L]
    RewriteRule ^member/([-a-zA-Z0-9_]*)/([-a-zA-Z0-9_]*)/[-a-zA-Z0-9_]*\.html$ index.php?mod=member&catID=$1&src=$2 [L]
    RewriteRule ^member/([-a-zA-Z0-9_]*)/([-a-zA-Z0-9_]*)/([-a-zA-Z0-9_]*)/[-a-zA-Z0-9_]*\.html$ index.php?mod=member&catID=$1&src=$2&p=$3 [L]

    but still i think there's better way to have the repetition format in single line

    please help

IMN logo majestic logo threadwatch logo seochat tools logo