This is a discussion on mod_rewrite with URLs as parameters (newbie) within the Apache Web Server forums, part of the Web Server and Related Forums category; I have set up very simple mod_rewrite rules as follows on Apache 1.3.34 running w/ PHP 5.1....
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have set up very simple mod_rewrite rules as follows on Apache 1.3.34
running w/ PHP 5.1.2. This is in the .htaccess file: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*) index.php So, from my script's perspective, the entire request comes in as a single string which my application parses out. This works fine for most situations like this: http://www.mysite.com/root/parameter...er2/parameter3 etc... My script would get: "/root/parameter1/parameter2/parameter3" The problem occurs when I want parameter2 to be a url, say http://www.cnn.com Even when encoded, apache either does not pass this properly or gives me a 404 error. I realize this is a very basic rewrite configuration. The link would look something like: http://www.mysite.com/something/jump...w.yoursite.com The same applies when I would pass a search string (or any string) as part of the URL which may contain characters that cause problems. What am I doing wrong? Thanks in advance. |
|
|||
|
jober2 wrote:
> I have set up very simple mod_rewrite rules as follows on Apache 1.3.34 [...] > http://www.mysite.com/something/jump...w.yoursite.com You have an encoded slash (%2F) here, which is not allowed. The request will end up in a 404 immediately, before mod_rewrite is reached. Encoded slashes can be allowed with the AllowEncodedSlashes-direktive in httpd.conf from apache > 2.0.46. See http://httpd.apache.org/docs/2.2/mod...encodedslashes You might try to double-encode your string % --> %25 like /something/jumpto/http%253A%252F%252Fwww.yoursite.com which should work. Anyway, I would avoid such characters in an URL, if possible. -- Robert |
|
|||
|
Robert Ionescu <robsiegen@googlemail.com> wrote in
news:ds8fr0$kfr$1@online.de: > Encoded slashes can be allowed with the AllowEncodedSlashes-direktive > in httpd.conf from apache > 2.0.46. See > http://httpd.apache.org/docs/2.2/mod...encodedslashes > > You might try to double-encode your string % --> %25 like > /something/jumpto/http%253A%252F%252Fwww.yoursite.com which should > work. > > Anyway, I would avoid such characters in an URL, if possible. > Excellent, thank you for the clear response. I will continue to append these "slash-prone" arguments in the traditional way using '?' or via post. This method seems to coexist nicely with apache/php. Thanks for the quick reply. Rob |