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.
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]
Related
My site is being attacked.
What I've done:
In the .htaccess file, about 4200 IP-addresses are blocked, with which requests were sent in batches in this way:
allow from all
deny from 200.6.169.250
deny from 85.109.127.48
All requests come from a single user agent.
How to block the user agent correctly
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 OPR/71.0.3770.284?
Yes, at the moment I wrote this and I do not know if there is a correct option here?
# Blocking user agents:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 OPR/71.0.3770.284" [OR]
RewriteCond %{HTTP_USER_AGENT} "=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36" [OR]
RewriteCond %{HTTP_USER_AGENT} "^Mozilla/5\.0 (Windows NT 10\.0; Win64; x64) AppleWebKit/537\.36 (KHTML, like Gecko) Chrome/85\.0\.4183\.121 Safari/537\.36" [OR]
RewriteCond %{HTTP_USER_AGENT} "^Mozilla\/5\.0 \(Windows NT 10\.0; Win64; x64\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) Chrome\/85\.0\.4183\.121 Safari\/537\.36$"
RewriteRule ^ - [F]
I am seeing this same attack. Blocking that browser string (as opposed to the IP's, which are all over the place) seems like the best call. I tend to suspect a browser or some exploit as a potential cause, given the pace of the attack, IP variability, and network speed differences. Unless it is a bot network that is attacking many places at once?
Note that we've seen what looks to be legitimate traffic from the longer versions of the browser string: i.e. additional info in the agent string beyond the Safari/537.36 appear legitimate, while only those that end at that exact point appear to be definite bots of some sort - at least, at this time.
If you'd like to block all the variations, the following works:
# Blocking user agents:
RewriteEngine On
RewriteCond "%{HTTP_USER_AGENT}" "^Mozilla/5\.0 \(Windows NT 10\.0; Win64; x64\) AppleWebKit/537\.36 \(KHTML, like Gecko\) Chrome/85\.0\.4183\.121 Safari/537\.36.*$"
RewriteRule ^ - [F]
Escaping the parenthesis is required (as you did in your last condition) since the RewriteCond expects regular expressions by default. While the dots would have been fine, I preferred being explicit. (For whatever reason, Apache doesn't care that /'s are not escaped - their documentation even includes examples like this too.)
Note that you don't have to use Regex if you want to block just one specific string, by using = as follows. No escaping needed in this case, but the quotes are:
RewriteCond "%{HTTP_USER_AGENT}" "=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"
I recommend doing testing with something like https://addons.mozilla.org/en-US/firefox/addon/user-agent-string-switcher/ Other common tools (e.g. curl) are great for it too: https://www.cyberciti.biz/faq/curl-set-user-agent-command-linux-unix/
# Blocking user agents:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 OPR/71.0.3770.284" [OR]
RewriteCond %{HTTP_USER_AGENT} "^Mozilla\/5\.0 \(Windows NT 10\.0\; Win64\; x64\) AppleWebKit\/537\.36 \(KHTML\, like Gecko\) Chrome\/85\.0\.4183\.121 Safari\/537\.36 OPR\/71\.0\.3770\.284" [OR]
RewriteCond %{HTTP_USER_AGENT} "^Mozilla\/5\.0 \(Windows NT 10\.0\; Win64\; x64\) AppleWebKit\/537\.36 \(KHTML\, like Gecko\) Chrome\/85\.0\.4183\.121 Safari\/537\.36\ (.*)$"
RewriteRule ^.*$ - [F]
The first and second locks are the same, while the third allows you to change the line endings. You can leave only one to choose from. It depends on what is required.
I have a problem with Pinterest : a pin to a page of my website has pushed away my own page from Google results.
I would like to block any crawl or new pin of this specific page from Pinterest
Pinterest User Agent is :
Pinterest/0.2 (+https://www.pinterest.com/bot.html)
Mozilla/5.0 (compatible ; Pinterestbot/1.0 ; +https://www.pinterest.com/bot.html)
Mozilla/5.0 (Linux ; Android 6.0.1 ; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Pinterestbot/1.0; +https://www.pinterest.com/bot.html)
Pinterest Bot IP range is :
54.236.1.XXX.
For the example, the page I want to block contains "substring" in it's URL
Here is my code in .htaccess and obviously it's not working :
RewriteEngine On
RewriteCond %{REQUEST_URI} substring [NC]
RewriteCond %{HTTP_USER_AGENT} pinterest [NC,OR]
RewriteCond %{HTTP_REFERER} ^(www\.)?pinterest\. [NC,OR]
RewriteCond %{REMOTE_ADDR} ^54\.236\.1\.
RewriteRule .* - [F]
Thank you for your help !
I'm trying to block 1 specific user that is constantly scraping my site by hand. He uses a VPN, so IP blocking doesn't work. I can't seem to get him blocked via my HTaccess file. I'm using the following code which is the escaped version of this user agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36 OPR/65.0.3467.48
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
SetEnvIfNoCase User-Agent "Chrome version 0\.0 running on Win10 Mozilla\/5\.0 \(Windows NT 10\.0; Win64; x64\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) Chrome\/78\.0\.3904\.97 Safari\/537\.36 OPR\/65\.0\.3467\.48" bad_bot
Deny from env=bad_bot
</IfModule>
Does this make any sense? I don't want to block too many other users with this piece of code, but I'm afraid that user agent is quite common.
Thanks in advance!
Ps. This goes way beyond my knowledge, but feel free to drop in any technical solutions or language and I'll figure it out with a dev friend.
Chrome redirects to mobile version, on a desktop.
I have a website and it has a iphone version that redirect iphones and safari users to a mobile version of the website.
The chrome browser on a desktop redirect also to the iphone/mobile version of the website.
Only this i dont want.
Other browsers like Mozilla and internet explore are working fine.
In my .htaccess file i have :
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} iPhone
RewriteCond %{REQUEST_URI} !^/iphone/
RewriteRule .* /iphone/ [R]
RewriteCond %{HTTP_USER_AGENT} Safari
RewriteCond %{REQUEST_URI} !^/iphone/
RewriteRule .* /iphone/ [R]
i have searched the web for many hour before asking here.
is there anyone who have experience with this type of bugs.
The website is html5, no php is used.
Regards iamdaves
Looking here you can see that the user agent string for Chrome also includes the keyword 'Safari'. Thus you might want to use something else to detect just the Safari browser.
Chrome 37.0.2049.0
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36
Perhaps 'Macintosh' or 'Mac OS'
Safari 5.1.7
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
Examples from www.useragentstring.com
I have a favicon.ico on my site.
In the HTML, I link to its location...
<link rel="icon" href="/assets/images/layout/favicon.ico" type="image/x-icon" />
I also have this in my .htaccess.
# Redirect /favicon.ico requests
RewriteCond %{REQUEST_URI} !^assets/images/layout/favicon\.ico [NC]
RewriteCond %{REQUEST_URI} ^favicon\.(gif|ico|png|jpe?g)$ [NC]
RewriteRule ^(.*)$ assets/images/layout/favicon.ico [R=301,L]
...to redirect the /favicon.ico requests to a different location.
For some reason, every time I request favicon.ico in my browser, I get 304 Not Modified response with matching Etags and apparently a blank image, even though /assets/images/layout/favicon.ico does exist.
I get the same issue when trying to access it wil the full path.
What is going on here? What is causing this 304?
First of all I would rather put this rule in .htaccess like this:
RewriteRule ^favicon\.(gif|ico|png|jpe?g)$ /assets/images/layout/favicon.ico [L,NC]
Then if you have this in your web page:
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
/favicon.ico will be internally redirected to /assets/images/layout/favicon.ico
I have tested this in IE, Firefox and Chrome and all 3 show this behavior that for the first time (or after clearing cache) I get 200 for favicon.ico but afterwards all browsers cache this icon file and don't bother to send another request to the server. With this setup I didn't find any 304 happening in my testing.
My access log:
Chrome
127.0.0.1 - - [05/May/2011:23:58:15 -0400] "GET /favicon.ico HTTP/1.1" 200 1150 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.24 (KHTML, like Geck
o) Chrome/11.0.696.60 Safari/534.24"
IE
127.0.0.1 - - [06/May/2011:00:05:18 -0400] "GET /favicon.ico HTTP/1.1" 200 1150 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .
NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
Firefox
127.0.0.1 - - [06/May/2011:00:07:33 -0400] "GET /favicon.ico HTTP/1.1" 200 1150 "-" "Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"
<IfModule mod_rewrite.c>
RewriteRule ^favicon\.ico$ _/img/ico/favicon.ico [L]
RewriteRule ^apple-touch-icon\.png$ _/img/ico/apple-touch-icon.png [L]
RewriteRule ^apple-touch-icon-precomposed\.png$ _/img/ico/apple-touch-icon-precomposed.png [L]
RewriteRule ^apple-touch-icon-57x57-precomposed\.png$ _/img/ico/apple-touch-icon-57x57-precomposed.png [L]
RewriteRule ^apple-touch-icon-72x72-precomposed\.png$ _/img/ico/apple-touch-icon-72x72-precomposed.png [L]
RewriteRule ^apple-touch-icon-144x144-precomposed\.png$ _/img/ico/apple-touch-icon-144x144-precomposed.png [L]
RewriteRule ^apple-touch-icon-114x114-precomposed\.png$ _/img/ico/apple-touch-icon-114x114-precomposed.png [L]