mod_rewrite with URLs as parameters (newbie)

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....


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-06-2006
jober2
 
Posts: n/a
Default mod_rewrite with URLs as parameters (newbie)

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.






  #2 (permalink)  
Old 02-06-2006
Robert Ionescu
 
Posts: n/a
Default Re: mod_rewrite with URLs as parameters (newbie)

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
  #3 (permalink)  
Old 02-06-2006
jober2
 
Posts: n/a
Default Re: mod_rewrite with URLs as parameters (newbie)

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:35 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0