Get rid of the “Page Cannot Be Displayed” error on your website
How many times have you clicked a link or followed a search engine to land on a page that has no information display and says, “the page cannot be displayed”? Many a times, huh? What do you do next? Do you move up the directory level? Or do you slice the URL and visit the webpage? Not many do that. The best practice that majority of the web surfers will follow is use the ‘back’ button and visit another website. Isn’t that what you do as well?
How to let this not happen to your website/blog? Is it possible? Yes. Follow this guide to understand where these pages might appear from, how to fix them and how to improve the user experience on your website.
What causes a 404 error?
A 404 not found might be caused due to many reasons. The website is redesigned and within the new directory structure, you move the pages and the links that were pointing to the old URL now no more find that page. The solution is setting up a custom 301 redirect from the old page to the new page which we are going to discuss in a coming post on Bhopu.
The other reasons might include changing the name of a page from xyz.html to abc.html (and again not using 301 redirection), mistyping on the part of users see your URL from a print brochure/business card or print ad, accidental use of incorrect URL when we syndicate content to other websites, missing favicon.ico file (when you open a webpage in a browser on the left side, adjacent to the URL, it shows an image, if that image is missing, the browser renders a 404) and use of expired domains which show weird results.
How to identify 404 errors?
The best way to identify the pages that are returning a “page not found” error on your website is to use Google’s webmaster central. The webmaster tools holds a sea of information for your website including who’s linking to you, the search queries that your site shows up for, the search queries that lead visitors to your website, the ability to create an XML sitemap and much more.
Within webmaster tools, you can also find the required solution – finding the pages that are causing a 404 error. This is vital information, but you find more. Google also tells you the pages that are linking to a 404 page. This wealth of information lets you understand the cause of 404. Go to the URL (internal or external) and then try to get it fixed. This can be done by contacting the webmaster of the website which is linking to you. If it is an internal link (a link that originates from your own site, just ask your webmaster to update the link or set up a 301 redirect from the old URL to the newer one.
Google Crawls Them
Google keeps looking for pages that return a 404 error. This behavior might bewilder some people. The main reason is that say if you took an old domain from a domain registrar and now put up pages with the exact same name which the old site had named as (something like /about.html or/contact.html). If Google were to drop them from its index, your new pages will never get in Google’s index. Always remember that crawling and ranking are two different aspects and in 99% of cases, these pages won’t ever rank well for a search query.
Fixing 404 Errors
a) On apache Web Server
On Apache, you have a file called .htaccess. Yes, that is the filename and it starts with a period. You should have access to modify this file on your server. If you don’t, please ask your host to intervene. Once you gain access to this file, (or have to create a new one using text editor) you need to enter the following line to this file:
ErrorDocument 404 /notfound.html
You may decide to change the name of the file to anything you like. The directive ErrorDocument 404 tells the server to use the notfound.html file whenever it cannot find a page that is requested. You need to create a file with this name at the root level of your web server. You can also exercise this control at each directory level, if you wish so. The local .htaccess file will overwrite the directives of the global .htaccess file.
b) On Microsoft IIS server
a) Choose the website for which you want to set the custom 404 error page.
b) Click on Properties
c) Click on Custom Errors tab.
d) Select the 404 HTTP error on the left column from the list of all errors.
e) On the right column you will see a file associated with it.
f) You can edit and customize this file.
c) On a wordpress blog
Majority of the Wordpress themes carry a 404.php file which is always shown when the visitors land on a blog post that is not present. Here is how you can edit your theme’s 404 template:
- Go to your WordPress admin panel and choose the Design menu.
- Choose the Theme Editor page.
- Check if your theme includes a ‘404 Template’ in the list of files.
- Click the link for ‘404 template’ on the right side of the page.
- Edit the message text to communicate and save your changes.
If your theme doesn’t have a 404.php file, you can use the 404.php from the default Wordpress theme or save your index.php file as 404.php and delete all its content.
d) On a Joomla CMS
Create a new article page that you want to display for your users when a page displays 404. Now, in your “template” directory, create a file called “error.php” and add the following code:
<?php
defined( ‘_JEXEC’ ) or die( ‘Restricted index access’ );
if (($this->error->code) == ‘404′) {
header(’Location: ‘ . $this->baseurl . ‘URL’);
exit;
}
where URL corresponds to the relative path of the article page.
Creating a ‘Custom’ 404 page
The custom 404 page should carry some vital information other than just displaying that the page cannot be found. Following ideas shall help users understand what you site is about and where can they find the information that they were looking for:
1. Always link to your homepage. If you are using category specific error pages, link to the category index page.
2. If you have a search box on your website, use it.
3. Link to the site map.
4. Provide the link to “best content” or “top pages” on your website/blog.
5. Any global navigation elements that your website has shouldn’t be missing from the custom 404 page.
Testing the Error Document
Make all the changes that are required on your CMS/web server and then type any URL that you know doesn’t exits on your website. Your error page should load up. Also test the search box, home page links and the other navigational elements.

Thanks, I used your htaccess 404 line and it worked great, got my own custom 404 page up now!