简体   繁体   English

htaccess mod用多个查询参数重写

[英]htaccess mod rewrite with multiple query parameters

I can't quite get this redirect right. 我无法完全正确地执行此重定向。 I want to redirect a legacy url http://www.example.com/product/page.php?item=AB123-AB123&upc=12345678910&c=1234 我想重定向旧网址http://www.example.com/product/page.php?item=AB123-AB123&upc=12345678910&c=1234

to

http://www.example.com/product/AB123-AB123 http://www.example.com/product/AB123-AB123

There will be variations of the url. 网址会有变化。 ie google anlyatics tracking code or other query parameters. 即谷歌分析跟踪代码或其他查询参数。 The only portion of the query string I need is item=AB123-AB123. 我需要的查询字符串的唯一部分是item = AB123-AB123。 I don't care about anything after that, although it would be nice to carry the remaining query string. 在那之后我什么都不关心,尽管携带剩余的查询字符串会很好。 http://www.example.com/product/AB123-AB123?upc=12345678910&c=1234 http://www.example.com/product/AB123-AB123?upc=12345678910&c=1234

I have tried as suggested: RewriteRule ^product/([^/]*)$ /product/page.php?item=$1&upc=12345678910&c=1234 [L] 我已按照建议尝试:RewriteRule ^ product /([[^ /] *)$ /product/page.php?item=$1&upc=12345678910&c=1234 [L]

but I receive a 404 error. 但我收到404错误。 I've verified the resulting page is correct and active. 我已验证结果页面正确且有效。 ie http://www.example.com/product/AB123-AB123 http://www.example.com/product/AB123-AB123

Try : 尝试:

 RewriteRule ^product/([^/]*)/?$ /product/page.php?item=$1 [QSA,NC,L]

Querystrings automatically get appended to the destination url. 查询字符串会自动附加到目标网址。

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

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