Fixing Your 404 Errors for SEO
First, Find If You Have Any 404 Error Pages
Step 1) Download & Open SEO Spider From Screaming Frog (https://www.screamingfrog.co.uk/seo-spider/)
Screaming Frog is a desktop-app (not a web-app) that will export a list of all of your website’s 404 errors.
Step 2) Enter the URL of your website
Step 3) Export Results
Modify Your .htaccess File To Redirect Error Pages
How To Access Your .htaccess File
You may choose to access your .htaccess file via FTP (use an FTP client like Filezilla and FTP credentials from your hosting provider to access your .htaccess file).
However, if you are using WordPress, consider downloading WP Htaccess Editor plugin by Lukenzi to access your htaccess file.
Step 4) Decide Where Your 404 Error Pages Should Go
Have you looked at your Screaming Frog report yet? Do you see any pages with 404 errors?
If so, those pages are giving visitors an error when they are visited. To prevent these errors, we need to redirect visitors to either:
A) a more appropriate landing page, or
B) the homepage of your website
Step 5) Add This Code To .htaccess
Using these examples as reference, add your redirects to the very bottom of your .htaccess file, one line per redirect, by replacing the red text (your error page) with the green text of your new page or homepage.
Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html
Redirect 301 /oldpage2.html http://www.yoursite.com/folder/
Redirect 301 /shop/product-xyz/ http://www.yoursite.com/
What If I Have A Lot Of Error Pages? Do I Have To Add All Of Them?
There are many tricks you can use to redirect large amounts of pages. Many of them involve rules and wildcards so that pages that meet certain criteria will all redirect to one page.
Since these custom mass redirects are a case-by-case basis, I recommend doing a quick Google search including the terms “htaccess”, “301”, “redirect”, and “wildcard” to find your own custom solution.
BONUS TIP (For WordPress Users)
NOTE: Use this tip only if all 404 Errors should redirect to the homepage of your website.
Download, install, & run the 404 to 301 plugin by Joel James before downloading the Screaming Frog report.
Why? You may find that this plugin solves most, if not all, of your 404 errors without any complicated edits to your .htaccess file.