Get money
Get money

Reputation: 11

Redirect specific useragent using HTaccess

Due to Gmail/Google opens all emails I send to check content and links I see inflated Open Rates. Around 80% of emails get checked by Gmail, so my open rates show 80%.

Most ESPs solved this by excluding opens and clicks from this Useragent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246 Mozilla/5.0".

So what I want to do now is to redirect any request with this user agent to a new url, so it can not access/download the tracking pixel in the email.

I heard you can do this in the htaccess file. I found numerous codes to redirect user agents but none of them shows an example to only redirect a very specific user agent string.

I found codes like this:

RewriteCond %{HTTP_USER_AGENT} Opera
RewriteRule ^abc.html$ http://example.com/xy/opera.html [R=301]

But it always says "Firefox" or things like "googlebot". Is there any way to ONLY redirect THIS SPECIFIC string?

I have no knowledge about this stuff at all and hope to get a copy paste solution.

The url I want do rediret to is beseductiv.com

Thank you very much.

Upvotes: 1

Views: 798

Answers (1)

RavinderSingh13
RavinderSingh13

Reputation: 133760

Could you please try following, written based on your shown samples.

RewriteEngine ON
RewriteCond %{HTTP_USER_AGENT} ^(Mozilla|Safari|googlebot).*$ [NC]
RewriteRule ^(.*)$ http://example.com/xy/opera.html [R=301,L]

Upvotes: 1

Related Questions