Are you tired of bots wreaking havoc on your 404 logs? Just add these redirections rules to solve simple yet annoying, repetitive errors.
Link Issues
If you’ve ever added a Telephone, Email, or even a Website link to your pages, you’ll generally find 404 errors related to them in your logs. Some of these issues may be that you typed them in wrong in the first, while others are just dumb search bots that have nothing better to do.
^/(.*)/#(.*) https://yourwebsite.com/$1#$2
Removes the trailing slash before the # HTML anchor, so any section link on your page (id=”anchor)” will only load the page it’s on.
^/tel:(.*) tel:$1
Removes https://yourwebsite.com/tel: error
^(.*)/tel+(.*) tel:+$2
Removes https://yourwebsite.com/any/subdirectory/tel: errors
^/mailto:(.*) mailto:$1
Removes https://yourwebsite.com/mailto: errors
^/www.(.*) www.$1
Removes your website link from https://yourwebsite.com/www. and Redirects it into an external www. link.
^/(.*)/null https://yourwebsite.com/$1
Removes the word null that follows the trailing slash in any website link.
^/(.*)/undefined https://traveldir.co/$1
Removes the word undefined that follows the trailing slash in any website link.
Characters & Symbols
These 404 hits are generally BAD BOTS looking to hack your website. These error links contain spaces, commas, and greater than/less than symbols.
To track these bad bots, redirect to a page no normal visitor can access. Then add these lines to your .htaccess file so these bots never actually see your website, just a blank page.
You can also redirect it to another page we use for search engine specific issues (/gone/)
ErrorDocument 410 default Redirect gone /bad-bot/ Redirect gone /gone/
Sets the default error page for 410 gone errors which all bots, including search engines, get told that this file no longer exists and there is a forwarding URL for it.
^/(.*) (.*) https://yourwebsite.com/bad-bot/
Redirects any link that contains a Space character or %20 URL encoding to a 410 Gone page where you can track bad bots.
^/(.*),(.*) https://yourwebsite.com/bad-bot/
Redirects any link that contains a Comma character or %2C URL encoding to a 410 Gone page where you can track bad bots.
^/(.*)<(.*) https://yourwebsite.com/bad-bot/
Redirects any link that contains a Less Than symbol or %3C URL encoding to a 410 Gone page where you can track bad bots.
^/(.*)>(.*) https://yourwebsite.com/bad-bot/
Redirects any link that contains a Greater Than symbol or %3D URL encoding to a 410 Gone page where you can track bad bots.