Recently rebuilt a site that was on wordpress to Craft CMS, and I am seeing a ton of hits trying to find files in /wp-content - Is there a way I can just set Retour to catch any request for anything in the /wp-content directory are redirect it to a single image file?
2 Answers
FWIW, I would actually recommend doing this rewrite at the web server level, because then these accesses will have a much lower impact on your site.
If you add the redirect to Nginx (or whatever your webserver is), these bot-spam hits won't have to cause Nginx, Craft, etc. to kick in before they operate. An example is here for Nginx:
https://github.com/nystudio107/nginx-craft/blob/master/sites-available/somedomain.com.conf#L72
# For WordPress bots/users
location ~ ^/(wp-login|wp-admin|wp-config|wp-content|wp-includes|xmlrpc) {
return 301 https://wordpress.com/wp-login.php;
}
Got it. Figured I would keep this here for anyone else looking to do this (or similar).
.*/wp-content($|/.*)