In my last article we looked at my Top 7 WP Plugins for Dealing With 404 Errors & helping to prevent them from ocurring, but that isn’t much help if you already have a huge amount of 404 errors. Therefore this article is going to show you a fairly easy method I use to Fix 404 Errors & Remove From Google.
If you don’t already have it installed, then click the following link to download and install Notepad++ (This script is ideal for working on templates, html & php code, so is highly recommended). The only other thing your going to need is MS Excel or the OpenOffice equivelant.
It is quite possible through neglecting to deal with these errors as they occur, that a situation can arise where you find yourself having to deal with thousands of these errors ! (A daunting task to say the least). So let’s look at a fairly easy way of doing this.
Steps To Fix 404 Errors & Remove From Google
Step 1. Your going to need a list of all your blog category urls.
Note: There are several ways of getting this list, write it out manually, use a php script from WordPress or I guess the easiest would be to add your categories to your sitemap.xml, then open the sitemap & take a copy of all the category listings. Then edit sitemap to remove categories.
Step 2. Go to Google’s Webmaster Tools & download a copy of all the 404 errors for your site (download as csv)
Step 3. Open the downloaded file in Excel or equivelant (if using OpenOffice)
Step 4. Highlight and delete columns B,C,D & E (These are not required for what we are doing)
Step 5. Expand the width of column ‘A’to accomodate the list of links
Step 6. Sort list alphabetically as this will help to group similar links together & speed up the fixing process.
Step 7. Highlight & copy the entire list and then open Notepad++ & paste in the list of sorted URLs.
Step 8. Using “‘Search & Replace” remove – “http://your-domain.com/” & replace with “Redirect 301 /”
Note: you must highlight all entries using edit/select all otherwise this will not work.
Step 9. In the Search & Replace window, click replace all.
Step 10. Copy the resulting entries & return to the Excel sheet. Delete the entries in the Excel sheet & paste in the entries from Notpad++
Then you simply need to read down the list of 404 errors & choose the most suitable category from your list of category urls, copy the relevant URL and then paste onto the end of the edited 404 error.
Note: YOU MUST LEAVE A SPACE! AS SHOWN BELOW.
Redirect 301 /some-missing/post-title/ http://your-domain.com/chosen-category/ (Note the space between post-title/ http:)
You can also Redirect an entire directory for instance you may have /test/comment-policy/ which may be redirected to http://your-domain.com/comment-policy/ by using – RedirectMatch 301 /test/(.*) //$1 (replace the word ‘test’ with the title of the directory you want to redirect.
To sit down and try to read through hundreds of post titles to try and find a suitable match for a 404 error simply is not practical, but to direct a visitor to the same category as the missing page is far more likely to give the visitor what they were looking for in the first place & is not likely to be frowned upon as much as simply sending the visitor to the home page!
Once you’ve fixed any 404 errors & removed from Google’s Webmaster Tools, I suggest that in future you deal with these errors as & when the occur. After all dealing with one or two errors would only take a couple of minutes, yet having to deal with hundreds or possibly thousands of these errors could literally take you hours to complete.
These May Also Be Of Interest..?