简体   繁体   English

301.由于正则表达式,htaccess重定向不起作用

[英]301. htaccess redirect not working due to regex

I have a little bit of trouble with a redirect 我在重定向时遇到了一些麻烦

I'd like to redirect every incoming traffic from 我想重定向所有来自

http://domain.com/?friends=7 to http://domain.com/win http://domain.com/?friends=7http://domain.com/win

I am using this rule, but it does not seem to work. 我正在使用此规则,但它似乎不起作用。

RewriteRule ^\?friends\=7$ /win [R=301]

You can't catch a query string with a RewriteRule you need to use a RewriteCond for this task: 您无法使用RewriteRule捕获查询字符串,而需要为此任务使用RewriteCond

RewriteBase /
RewriteCond %{QUERY_STRING} ^friends=7$
RewriteRule ^$ /win? [L,R=301]

You can test your RewriteRule using this tool 您可以使用此工具测试RewriteRule

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

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