mod_rewrite help :s I'm confused

Discussion in 'Apache' started by moviedrome, May 1, 2009.

  1. #1
    Hi, sorry if this is really basic but i'm a bit confused.

    I currently use modrewrite as follows:

    RewriteRule ^([0-9]+) http://www.mydomain.co.uk/?id=$1 [nc]

    which as i'm sure you're aware turns this http://www.mydomain.co.uk/123 into http://www.mydomain.co.uk/?id=123

    Well i have an issue because i'd like to have it kind of like an if statement:

    i'd like http://www.mydomain.co.uk/cheese to rewrite to http://www.mydomain.co.uk/?name=cheese but if it's numeric as above sp http://www.mydomain.co.uk/123 to still go to http://www.mydomain.co.uk/?id=123

    So the variable would be ?name= if text (and numeric, i'd still want it to be ?name= if the word after the / was cheese123cheese) but ?id= if solely numeric

    is this possible? :confused:
    hope that makes sense
     
    moviedrome, May 1, 2009 IP
  2. SSANZ

    SSANZ Peon

    Messages:
    861
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    SSANZ, May 2, 2009 IP
  3. Lpe04

    Lpe04 Peon

    Messages:
    579
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    RewriteRule ^([0-9]+) http://www.mydomain.co.uk/?id=$1 [nc,L]
    RewriteRule ^([a-z0-9]+) http://www.mydomain.co.uk/?name=$1 [nc]
    
    Code (markup):
     
    Lpe04, May 4, 2009 IP