Search code examples
.htaccessdrupal-7

.htaccess to prevent hitbots URI "payday" and "loans"


One of my Drupal servers was recently hacked. Although it's clean now, I get lots of Google traffic for /payday-loans and /leasehold-loans and similar. They have generated enough traffic to slowdown my website and especially mysql. What is the correct code for .htaccess to redirect (or just stop) all URIs containing payday or loans? I'd like to handle these requests at the apache level--prior to PHP and mysql processing them.


Solution

  • Try adding this above any rewrite rules that you may already have:

    RewriteEngine On
    RewriteRule (?:payday|leasehold)-loans - [L,F]
    

    This will return a 403 forbidden, but you may want to redirect to something else instead.

    RewriteEngine On
    RewriteRule (?:payday|leasehold)-loans https://google.com/ [L,R=301]
    

    This redirects any request with payday/leasehold-loans to google, or you can just 404 it:

    RewriteEngine On
    RewriteRule (?:payday|leasehold)-loans - [L,R=404]