Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

blanka

macrumors 68000
Original poster
Jul 30, 2012
1,551
4
I'm trying to get a mod_rewrite rule working:

Code:
RewriteRule ^item/(.*)/(.*)\.html?code=(.*)$ item.php?brand=$1&title=$2&code=$3
RewriteRule ^item/(.*)/(.*)\.html$ item.php?brand=$1&title=$2

These are the .htaccess rules

When I use the url
/item/brand/product.html?code=sessionid it activates the second rule, not the first. I want the sessionid to end up in GET variable "code"

What do I do wrong?
 
Found the solution:

You just need this (the [QSA], with L if it is the last rule):
Code:
RewriteRule ^item/(.*)/(.*)\.html$ item.php?brand=$1&title=$2 [QSA,L]
It puts the original variables behind the new URL.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.