mod rewrite from one page with ?option= to another website page

Discussion in 'Apache' started by hmc, Apr 20, 2010.

  1. #1
    hmc, Apr 20, 2010 IP
  2. TomDeLonge

    TomDeLonge Peon

    Messages:
    119
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    TomDeLonge, Apr 22, 2010 IP
  3. hmc

    hmc Peon

    Messages:
    354
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    no mate doest work.

    anyone can help pls?
     
    hmc, Apr 27, 2010 IP
  4. TomDeLonge

    TomDeLonge Peon

    Messages:
    119
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Its hard to say what is going on on your server without looking at ErrorLog. May be you can post here what errors do you get.
     
    TomDeLonge, Apr 27, 2010 IP
  5. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #5
    RewriteRule doesn't look at the querystring (everything after "?") when seeing if there's a match. It only looks at the URI ("/path/to/file.html")
    You need to setup RewriteRule to match a URI, which in your case will be "index\.php$" and then you need to use RewriteCond to match the querystring.
     
    joebert, Apr 28, 2010 IP
  6. TomDeLonge

    TomDeLonge Peon

    Messages:
    119
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Have to disagree here.
    So, to replace URL completely you need to have (.*) in your pattern
     
    TomDeLonge, Apr 28, 2010 IP
  7. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #7
    You're not interpreting the manual correctly Tom.

    I'm telling you from experience, mod_rewrite splits the URI and QUERY_STRING apart before applying the pattern from RewriteRule.

    Here, look. This is generated with RewriteLogLevel set to 9, the most verbose.
     
    joebert, Apr 28, 2010 IP
  8. TomDeLonge

    TomDeLonge Peon

    Messages:
    119
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Yes you are right. I got confused by a lot of examples where (.*) was used whether it was necessary or not. [R] tells it to rewrite whole URL.
     
    TomDeLonge, Apr 28, 2010 IP
  9. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #9
    I used to get confused about the same thing when I started with mod_rewrite. I definitely don't remember it seeming very straight forward in the beginning, there was a lot of "I before E except after C" type rules about it. :)
     
    joebert, May 1, 2010 IP