Tobi
Tobi

Reputation: 23

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]

Upvotes: 0

Views: 81

Answers (1)

Florian Lemaitre
Florian Lemaitre

Reputation: 5748

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

Upvotes: 1

Related Questions