httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joshua Slive <jos...@slive.ca>
Subject Re: [users@httpd] mod_rewrite & query strings -> php variables, sessions
Date Tue, 19 Nov 2002 18:44:28 GMT

On Tue, 19 Nov 2002, Georg Markus Dittrich wrote:
> to put it in a nutshell i would like to know, how i can include the
> query_string in rewrite rules not only on the output side, but on the
> incoming one (the URL, which has to be rewritten);

> RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)\.html\??(.*)
> $1\.php?category=$2\&item=$3\&shop_lang=$4\&type=$5\&$6

This is actually much simpler than you might think.  If you tag the option
[QSA] ("Query String Append") on to the end of the RewriteRule,
mod_rewrite will automatically grab the query string from the request and
add it to the query string of the target.  So you probably just want
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)\.html $1\.php?category=$2\&item=$3\&shop_lang=$4\&type=$5\&$6
[QSA]

In general, you can't match the query string with a RewriteRule.  You need
to use a RewriteCond and match agains %{QUERY_STRING}.

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message