Apache rewrite failing because of ? in URL string

Discussion in 'Apache' started by blazted, Mar 16, 2011.

  1. #1
    I am not very familiar with Apache Mod_rewrite. However I need to rewrite a URL string. I have a rewrite rule that is working but if the URL string has a ? in it it falls through.

    I am receiving a URL string like so:
    http://example.com/foo.xml?carrier=blah&platform=win

    If I receive a URL string like this I need to point it to where the foo.xml file live for that carrier.

    Here is a dirty Rewrite to show what is happening.

    RewriteRule ^/.*carrier=([a-z]).*$ /blah/$1/win/foo.xml [R]

    If I do a curl on http://example.com/foo.xml=carrier=test&platform=win I get the valid redirect

    applying pattern '^/.*carrier=([a-z]+).*$' to uri '/foo.xml=carrier=test' and it works. I end up getting redirected to http://example.com/blah/blah/win/foo.xml

    If I do a curl on the same url but have a ? after the foo.xml instead of a = I get a pass through and it only looks at the URL up to the ?

    curl http://example.com/foo.xml?carrier=test&platform=win

    applying pattern '^/.*carrier=([a-z]+).*$' to uri '/foo.xml='
    pass through /foo.xml=

    Now I get a 404 error.

    Any Ideas

    Thanks
     
    blazted, Mar 16, 2011 IP