Today my server was bloated with hundred of requests to the contact page of my site (/contact) in just 2 minutes.
I get hundred of these lines in my apache log:
*31.13.115.6 - - [18/Jun/2019:10:54:39 +0200] "GET /contacto HTTP/1.1" 301 331 "-" "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)" 232* *31.13.115.25 - - [18/Jun/2019:10:54:39 +0200] "GET /contacto HTTP/1.1" 301 331 "-" "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)" 232* I'm not sure what is the cause of this, but my server was down because of this. I want to make sure this will not happen again.
My server provider told that I can block these request adding a rule in my .htaccess using RewriteCond.
I know that I will have to use something like:
RewriteCond %{HTTP_USER_AGENT} "facebookexternalhit/1.1" but I have not much knowledge about this.
UPDATE for MrWhite:
I think that I know what could be the problem. I have an old site oldsite.com which is redirected to my new site newsite.com. In the htaccess of oldsite.com I added these lines to created the redirection:
Rules in oldsite.com/.htaccess
RewriteEngine on RewriteRule ^(.*)$ https://www.newsite.com/$1 [R=301,L]
This rule was created because I changed the domain of my site, then the goal of this rule is to redirect the traffic from the oldsite to the newsite without hurting SEO.
It worked fine until now. Do you think this could be the cause of this? If so, do you think I need to change this rule in www.oldsite.com/.htaccess instead of adding other rules in www.newsite.com/.htaccess ?
oldsite.comandnewsite.comaren't pointing to the same place, ie. they don't share the same.htaccessfile? Presumably the log entries you posted above are fromnewsite.com, notoldsite.com? What about HTTP vs HTTPS - these would normally be in separate logs. What are the log entries that follow the above? The redirect directives you posted above shouldn't be a problem. But if these requests are foroldsite.com(as opposed tonewsite.com) then these blocking directives need to be applied tooldsite.com, notnewsite.com.oldsite.comandnewsite.comreside on separate filesystems and you are simply redirecting from the old to the new and the log entires are from the new, then the redirect you posted above would seem to having nothing to do with this problem? The "301 redirects" in the log entries above are caused by something else atnewsite.com.