Mod Rewrite question

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

  1. blanka macrumors 68000

    Joined:
    Jul 30, 2012
    #1
    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?
     
  2. blanka thread starter macrumors 68000

    Joined:
    Jul 30, 2012
    #2
    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.
     

Share This Page