This is a discussion on Timing Sequence of Unescaping mod_rewrite within the Apache Web Server forums, part of the Web Server and Related Forums category; Got some weird results from mod_rewrite, and it had nothing to do with regular expressions; I was hoping someone could ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Got some weird results from mod_rewrite, and it had nothing to do with
regular expressions; I was hoping someone could explain to me what I was witnessing. For the sake of simplicity, let's say I'm trying to turn this ugly, if not illegal url: http://www.myserver.com/http://www.napkincomics.com/ Into: myscript.php?url=http://www.napkincomics.com/ The rule I'm using to do this: RewriteRule ^(http.*)$ myscript.php?URL=$1 [L] And, for the most part, it works. PHP's $_REQUEST['URL'] returns a value. Now, here comes the weirdness I'd like to get explained: 1) The string value that gets return for the example above is: http:/www.napkincomics.com/ Specifically, note that there is only _one_ slash, not _two_. It's as if everything after the host is treated as a directory, and Apache is helping me out by compressing // into /. My thought was that if I did a mod_rewrite and pushed the url into a legit form, where it was being passed a parameter, not a path, this kind of thing wouldn't happen. In short, I'd get there before that kind of damage would be done. 2) So, in trying to fake it out, I use %2F so that I could pass a slash in much the same way one passes %20 to pass a space. However in this case the regular expression doesn't match and the rewrite rule doesn't fire. I can't figure out why that'd be. The logs say that it's trying to access /http://www.napkincomics.com/ on the local server. It's as if the unescaping happens before the mod_rewrite rule. Is there any way to take exactly what the user passed to the server and manipulate it well before any of this other processing goes in? Thanks, Walt Stoneburner wls@wwco.com |