How to make /XXX/ point to filename.php?var=x? (mod rewrite)

Discussion in 'Apache' started by nudu, Apr 19, 2009.

  1. #1
    I want to make it so that "/XXX/" (which is not an existing file directory) points to "/filename.php?var=1"

    I want the imaginary /XXX/ to be in the same dir as /filename.php.

    Could anyone help me out with the .htaccess code I need to make this work?

    Thanks.
     
    nudu, Apr 19, 2009 IP
  2. Lpe04

    Lpe04 Peon

    Messages:
    579
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need the filepath be something that will be interpreted in the variable, so something like

    /123/ will redirect o /filename.php?var=123

    in this case

    RewriteRule ^/([a-zA-Z0-9]+)/$ /filename.php?var=$1 [L]

    Cheers,
     
    Lpe04, Apr 20, 2009 IP
  3. nudu

    nudu Banned

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you very much mate.
     
    nudu, May 3, 2009 IP
  4. Lpe04

    Lpe04 Peon

    Messages:
    579
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    sure, no problem ;)
     
    Lpe04, May 4, 2009 IP