2

I have a set of product pages that obey the following htaccess rule:

RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_URI} ^/([0-9]+)\-(.+)\.html
RewriteRule ^(.*)$ /product/index.php?prod=%1-%2 [L]

Which rewrites them to: example.com/123-1234.html.

My problem is that I can no longer pass additional $_GET variables to the page - IE: example.com/123-1234.html?coupon=something123.

Is there any way to do this?

beaudierman
  • 138
  • 1
  • 9
  • The whole point of mod_rewrite is to keep the url and uri intact. You can't access `$_GET['prod']`? The alternative would be to take the url and split it up using explode. – OptimusCrime Nov 22 '11 at 14:58

2 Answers2

9

Your looking for QSA, Query String Append

RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_URI} ^/([0-9]+)\-(.+)\.html
RewriteRule ^(.*)$ /product/index.php?prod=%1-%2 [L,QSA]
Lawrence Cherone
  • 46,049
  • 7
  • 62
  • 106
2

Add the QSA flag to pass along existing query string params

RewriteRule . /product/index.php?prod=%1-%2 [QSA,L]

Also edited match as . and ^.*$ are equivalent in this case

Ulrich Palha
  • 9,411
  • 3
  • 25
  • 31