Forum Moderators: phranque

Message Too Old, No Replies

Mod_Rewrite and passing through Query Strings

How to pass through portions of the query string...

         

javacado

7:28 pm on Mar 7, 2006 (gmt 0)



Hello

I have a rewrite rule that takes a url like:

/content/home.html

and with a rewriteMap then points it at:

/browse.php?page=NN

That part works brilliantly. What I would now like to do is be able to add a query string to the 'fake' URL and have it pass directly into the rewritten URL.

So:

/content/home.html?foo=true

rewrites to:

/browse.php?page=NN&foo=true

By using the map for the page=NN part and then another rewriteCond or rewriteRule to map the extra query string part.

I have searched far and wide and see there is a way to pass the query string through, but it seems I can't figure out how to combine the rewriteCond with the rewriteMap and the the rewiteRule

Here is what works now.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteLog logs/rewrite_log
RewriteLogLevel 1
RewriteMap categories txt:/lookupTable.txt
RewriteRule ^/content/(.*)$ /browse.php?page=${categories:$1¦2}
</IfModule>

Thanks for any assistance.

jdMorgan

8:16 pm on Mar 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



javacado,

Welcome to WebmasterWorld!

See the RewriteRule [QSA] flag. This makes it possible to append new query information to that in the request, or to that added as a result of a previous rewrite.

Jim