Mod Rewrite question

Discussion in 'Web Design and Development' started by blanka, Mar 29, 2014.

  1. blanka macrumors 68000

    Jul 30, 2012
    I'm trying to get a mod_rewrite rule working:

    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?
  2. blanka thread starter macrumors 68000

    Jul 30, 2012
    Found the solution:

    You just need this (the [QSA], with L if it is the last rule):
    RewriteRule ^item/(.*)/(.*)\.html$ item.php?brand=$1&title=$2 [QSA,L]
    It puts the original variables behind the new URL.

Share This Page