Help block a user agent

[ad_1]

Someone is sending offensive emails through all my forms, always changing IP and username, but their user agent is always the same, so I want to block them from accessing the web site, any one can help me with this? I know the risk of blocking someone legit along the way but we just don’t care anymore. I tried every possible combination in htaccess, none of them work… here is the user agent in question

User Agent: Mozilla/5.0 (iPad; CPU OS 6\_0 like Mac OS X) AppleWebKit/123.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/1234.25

[ad_2]
4 Comments
  1. To block this specific user agent, you can use the following code in your .htaccess file:

    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} ^Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/123.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/1234$
    RewriteRule .* – [F,L]

    Here’s how it works:

    * RewriteEngine On enables the rewrite engine.
    * RewriteCond %{HTTP_USER_AGENT} checks the user agent against the specified pattern.
    * The pattern is a regular expression that matches the exact user agent string you provided.
    * ^ and $ anchor the pattern to the beginning and end of the user agent string, respectively.
    * The RewriteRule directive specifies the action to take when the condition is met.
    * .* matches any URL (since you want to block access to the entire site).
    * [F,L] sets the response status to 403 Forbidden and stops processing any further rewrite rules.

    Add this code to your .htaccess file, and it should block any requests with the specified user agent. Keep in mind that this will only block requests with the exact user agent string. If the user changes their user agent slightly, this rule might not catch it.
    Also, be aware that blocking a user agent can potentially block legitimate users who happen to have the same user agent. However, given the situation you described, it seems like a reasonable approach to mitigate the issue.

  2. I’d get a security plugin like Wordfence and block the IP, blocking a user agent string will more than likely block other legitimate users and not really stop it as forging a user agent is really easy to do.

  3. Perhaps Cloudflare can help you. If this hint does not suffice, let me know and I’ll elaborate.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer