问题
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?
回答1:
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]
回答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
来源:https://stackoverflow.com/questions/8228793/get-variable-after-mod-rewrite