How to Fix a 404 Error

by Dan Stone

Your Web server will send your visitors "404 Not Found" errors, if they try to access page addresses and file locations where content doesn't exist. The 404 error means that the server couldn't find the requested content. While 404 errors are inevitable on the Web, it's the webmaster's job to make sure the errors don't come from internally controlled factors and try to keep visitors on the site when the errors occur.

The Cause of 404 Errors

The 404 error occurs when a file or location has been renamed, removed or deleted; files and locations can also be temporarily unavailable. When troubleshooting, you should determine why the 404 error is popping up and how people are encountering it. Sometimes the error is as simple as a typo, misplaced slash or case-sensitivity mistake.

Repairing Hardcoded Links

The process used to fix your bad links will differ, depending on whether you individually code pages and links in HTML or use a CMS system to generate them. To fix hard coded HTML links, check the URL placed after the "href" attribute in the <a> tag for errors. To correct the error, load the actual working page in your browser, copy the URL and paste the URL in the "href" attribute field. CMS systems may generate bad links if you've moved content or changed how the page generates links to content. For example, a CMS like WordPress may encounter errors in the permalink or link-array system that sends visitors to bad URLs. You can fix link array problems by forcing the CMS to rebuild or update the link array. If you're getting 404 errors because you moved content, you can either use a 301 redirect to forward visitors to the new location or move the content back to its original location.

Check Missing URLs

There's nothing you can do to code around a 404 error and make it work, if the content doesn't exist. If a file, like a picture, document or video, pull up your FTP client or CMS and look for the file in the directory implied by the URL and it simply isn't there, an error will occur. If the file or directory is not there the link is bad, if the file is there you may have a server error or a bad file. Try uploading the file to a new location and updating related links.

Custom 404 Pages

You can add a custom, useful 404 page to your website to send visitors who encounter 404 errors to something that will help them look for the content, instead of sending them away from your site. For example, it's a good practice to place things like your site map and site search on the custom 404 page. You can also use the 404 page to explain that the content can't be found in a polite, non-technical tone. Google says it is a bad idea to redirect your 404 page to another page, because it can harm search engine rankings.

About the Author

Dan Stone started writing professionally in 2006, specializing in education, technology and music. He is a web developer for a communications company and previously worked in television. Stone received a Bachelor of Arts in journalism and a Master of Arts in communication studies from Northern Illinois University.

Photo Credits

  • photo_camera monkeybusinessimages/iStock/Getty Images