Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite

get php url parameters

         

nevsk

1:11 am on Jun 18, 2004 (gmt 0)

10+ Year Member



Hi,

im trying to create a rule where i can get the page parameters from the url, but seems that i cant get them using mod_rewrite, is it right?

What i need is:

[mydomain.com...]

rewrite

[mydomain.com...]

I tryied this rule

RewriteRule ^((.+[^/])/?(\?)?(.+)?)$ /main.php?user=$2&$4 [L]

I also used php, just for test purpose, to output the querystring after the rewrite rule but i couldnt Backreference to the parameters.

Tks

jdMorgan

1:58 am on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use
RewriteCond %{QUERY_STRING} (.*)
to get the variables, and then back-reference them in the following RewriteRule using %1
The contents of {QUERY_STRING} will include the entire query, starting after the "?".
RewriteRule does not have direct access to the query string, except through %{QUERY_STRING} or through a back-reference to a RewriteCond pattern match.

Ref: Apache mod_rewrite documentation [httpd.apache.org]

Jim