简体   繁体   English

.htaccess重写与$ _GET参数的冲突

[英].htaccess rewrite clashing with $_GET parameters

So, integrating this third party tracking service that passes a $_GET parameter to our product pages. 因此,集成此第三方跟踪服务,将$ _GET参数传递给我们的产品页面。 The page is rewritten in .htaccess and they pass the query string starting with a question mark (?) and $_GET doesn't pick it up unless its an ampersand (&). 该页面在.htaccess中重写,它们以问号(?)开头传递查询字符串,$ _GET除非是&符号(&),否则不会将其取出。

So this is the htaccess rewrite. 所以这就是htaccess重写。

RewriteRule ^the-url/(.*?)/(.*?)/?$ /the-page.php?slug=$1/$2 [L]

This works 这有效

http://www.site.com/the-url/someones-name/a-title&something=4 http://www.site.com/the-url/someones-name/a-title&something=4

This does not (but I need it to. Notice the question mark rather than ampersand) 这不是(但我需要它。注意问号而不是&符号)

http://www.site.com/the-url/someones-name/a-title?something=4 http://www.site.com/the-url/someones-name/a-title?something=4

Thanks 谢谢

I guess you have to use the [QSA] flag: 我想你必须使用[QSA]标志:

RewriteRule ^the-url/(.*?)/(.*?)/?$ /the-page.php?slug=$1/$2 [L,QSA]

If this flag is set, the given query string will be appended (QSA = Query-String Append), not removed. 如果设置了此标志,则将追加给定的查询字符串(QSA = Query-String Append),而不是删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM