Tutorial

How to create a custom 404 error / page not found for your Dolphin site.

Some hosting accounts come pre-configured or setup with a 404 error page, others allow you to make one through your hosting control panel. Some of the hosts that have them pre-setup and configured will often have your host companies logo and info on the page. A sort of little advertisement for themselves if you will.

If your host does not have one pre-setup and configured for you or if you do not like the often generic simple look why not create your own custom 404 error page.

If you do not set up a 404 error page a visitor will often see a plain old generic white error page. Often times they will just assume your site is messed up, don't exist, or there is something wrong. These folks usually don't come back if they see this generic error page.

Why you should consider one...

Let's assume that you have a web page, any page really...it doesn't matter if we are talking about Dolphin or not. Say Google has indexed one of your webpages and someone finds the page in a Google search, clicks your link to your page, but your page no longer exists. Maybe you deleted the page, maybe it was a page to a photo or video a member uploaded and later deleted.

So when the casual visitor clicks on your link from the Google search they get the plain old 404 page not found error, or your hosts generic error page with your hosts logo.

So if we create a custom 404 error page that is based on the same layout and design as the rest of our site, it will look much more appealing to the visitor even though the page don't exist anymore. There is also a much better chance that they will actually check something else out as long as they are there.

To check what kind of error page someone might get when visiting your site you can simply type a page that don't exist into your web browser address bar.

We would want to use a .html or .php extension for a test to a page that don't exist. Try something more like yoursite.com/99999.html or similar and see what kind of error page you get.

Here is a screen shot of a custom 404 error page someone will see at my site. You can verify this by entering http://www.dialme.com/99999.html into your browser:


Custom Dolphin 404 Error Page



If you have a custom page already you will need to backup and rename the one that already exists on your hosting account. Usually this will be called 404.html and can be found in your root directory, such as yoursite.com/404.html. If you have one you will want to rename it to something like 404-bk.html or if it is 404.php rename it 404-bk.php.

If you do not have one you will also need to create the rule in your main .htaccess file located at yoursite.com/.htaccess

Before messing with .htaccess always download and backup this file. One little line or character out of whack and you can take your entire site down.

Then you will need to add the following line to your main .htaccess file:

ErrorDocument 404 /404.php

Save the changes to your .htaccess file and re-upload to your host.


Then we need to make the actual 404.php page with the same style and look as our Dolphin site.

There are several ways we can do this, but in this example I will use the fastest and easiest.

Download this pre-made 404.php error page and unzip it to your local pc.

Open the file and find near the bottom:

    return  <<<HTML
<br>
Page not found!! Please try again using the links in the navigation menu.
<br><br>
If you continue to have issues, please <a href="http://www.yoursite.com/contact.php" title="Contact Us">contact us.</a>
<br><br>
HTML;


Simply change anything in this part to the message you want your visitor that comes across a page not found to see. If you use this same one be sure you change yoursite.com to your actual site name.

Then save the changes and upload it to your hosting account...yoursite.com/404.php

Now to test it simply enter a name of a page that does not exist again like:
yoursite.com/999999.html

You should see this new error page/message and with a look and style just like your Dolphin site.

You are free to use any file name instead of 404.php. Simply update the changes to .htaccess with a different file name. Maybe you prefer notfound.php instead, or sorry.php. Then rename 404.php the same name as the one you put in .htaccess.

If you would like to change the page tile and address bar title you can do so too. In my example the title is "404 Page Not Found" as pictured above. To change this to another title open 404.php and find:
$_page['header'] = "404 Page Not Found";
$_page['header_text'] = "404 Page Not Found";

Simply Change to anything you like such as:
$_page['header'] = "Sorry";
$_page['header_text'] = "Sorry";

Save the changes and re-upload.

Overall this can be done in less than 15 mins. Maybe even 5-10 minutes for those of you more familiar with the hosting environment.

Good Luck and Have Fun!!

 
Written By
Tutorial by: Jeremy LeSarge (AKA Ray)

I am the owner and administrator of DialMe.com. I write Tutorials for Boonex Dolphin as well as tips and resources surrounding website programming and development. I enjoy working with WordPress, SEO, and Web Hosting / Servers. I also maintain a WordPress Blog here on this site where you will find a variety of technology and webmaster resources.

Actions
Recommend
Sponsored Links