Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite problem

how to pass?paramters through mod rewrite

         

iano99

8:21 pm on Mar 15, 2004 (gmt 0)

10+ Year Member



I've been trying (without luck) to pass a parameter through mod rewrite to a php page.

i.e /files/100/index.html?partner=123 to /files/index.php?c=100&partner=123

using the rule below generates 404 errors
/files/(.*)/index.html?partner=(.*)$ /files/index.php?c=$1&partner=$2

I've managed to pass it through without the? being used, but that would create an extra level in the directory structure which I don't want to do.

Can anyone help? Thanks

closed

3:42 am on Mar 17, 2004 (gmt 0)

10+ Year Member



The problem is that you aren't escaping the ? in the regular expression.

iano99

7:49 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



closed, thanks for the reply, but I'm still getting 404s. any ideas?

closed

8:44 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



If you post the code you're working with, people on this forum will probably be able to pinpoint your problem a lot better and faster.

iano99

10:46 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



RewriteEngine on
RewriteRule ^directory-allsport/files/(.*)/(.*)\.html\?(.*)$ directory-allsports/files/index.php?c=$1&$3

this rule produces a 404 error - The requested URL /directory-allsport/files/123/index.html was not found on this server - when using the url...
[domain.com...]

thanks
Ian

closed

11:28 pm on Mar 17, 2004 (gmt 0)

10+ Year Member



Okay, I think the problem is that the query string is stripped before it's evaluated in the pattern.

So you'd have to use a RewriteCond that checks QUERY_STRING. To get to the contents of its buffer from a RewriteRule, you'd use

%N
instead of
$N
(N is an integer).