Jared Eitnier
Jared Eitnier

Reputation: 7152

htaccess redirect url with domain as variable to an external site

I want to redirect

http://example.com/report?domain=dollarshaveclub.com

to

http://www.semrush.com/info/dollarshaveclub.com+%28by+organic%29

I've tried:

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^?domain=$
RewriteRule ^report$ http://www.semrush.com/info/$1+%28by+organic%29 [R=301,L]

But I'm not getting anywhere...What could I try next?

Upvotes: 0

Views: 94

Answers (2)

Jared Eitnier
Jared Eitnier

Reputation: 7152

Found the solution finally:

RewriteCond %{QUERY_STRING} ^domain=(.*)
RewriteRule ^report(.*) http://www.semrush.com/info/%1+(by+organic)? [R=301,L]

Upvotes: 0

Simone
Simone

Reputation: 21272

You must remove the R=301, part.

This works for me:

RewriteEngine On
RewriteRule ^report$ http://www.semrush.com/info/$1+%28by+organic%29 [NC]

Upvotes: 1

Related Questions