Block specific referrer or agent to enter url
-
Hello Forum,
since a few weeks I have goofy search requests in the log of the plugin search meter (the plugin monitors what users have searched for)Here is an example log:
REQUEST_URI: /search/www.ymwears.cn
REQUEST_METHOD: HEAD
QUERY_STRING:
REMOTE_ADDR: 193.112.39.200
HTTP_USER_AGENT: User-Agent=Mozilla/5.0 (compatible;googlebot/2.1)
HTTP_REFERER: https://www.google.com/bot.htmlWhat I figuered from this is that without entering my website a bot calls the URL https://www.mydomain.com/search/searchterm For what???
I would like to either block the REQUEST_URI for bots in the htaccess or only allow it if the referer is from inside mydomain
I think the allow solution is the better way as the bots seem to change and the list would be verry long. But so far I could not find a solution for this way.
What I tried is to block the HTTP_USER_AGENT with this code in the htaccess but it doesn’t seem to work.
RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ^$ [OR] RewriteCond %{HTTP_USER_AGENT} Agent [NC] RewriteRule ^.* - [F]
I thought that the above code would give every HTTP_USER_AGENT that has the sring Agent in his name a 403 error.
But I still have these search requests.
- The topic ‘Block specific referrer or agent to enter url’ is closed to new replies.