简体   繁体   中英

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

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:

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

You can test your RewriteRule using this tool

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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