Musings of a technophile

Just another blog from a computer nerd
  • Home
  • About Me
  • Funny things my kids say

How to make WordPress display a 404 page with GoDaddy hosting

ElementZero | January 30, 2009

Whenever you design a website, it is a good idea to even take the little things into consideration in order to make the user experience the best. That being said, I noticed the other day that anytime someone hit a 404 page to my site they received the GoDaddy error message for a 404, which is pretty generic. I looked inside my templates for WordPress and say that there is a 404.php template, but it was never called for some reason. My first guess was that the GoDaddy 404 superseded anything WordPress was trying to do; annoying at best.

I tried to change the options in the GoDaddy configuration to get it to not override the WordPress 404 page, but to no avail. Finally I opened the WordPress logic up and went through it and pulled out the code to make a static page I could give GoDaddy that would force it to use the WordPress 404 template, then set GoDaddy to hit that page on 404 errors. Problem solved!

If you would like to duplicate my steps, here is what you need to do.

Step 1: Make the file to force GoDaddy to use the WordPress 404 page

First, open up a text editor (notepad, nano, whatever) and put the following in the file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
// Make the page return a 404 status for SEO purposes
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found"); 
 
// Now force the normal 404 error WordPress logic
define('WP_USE_THEMES', true);
 
if ( !isset($wp_did_header) ) 
{
	$wp_did_header = true;
 
	require_once( dirname(__FILE__) . '/wp-load.php' );
 
	wp();
 
	if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) 
	{
		do_action('template_redirect');
		if ($template = get_404_template()) 
		{
			include($template);
			return;
		}
	}
}
?>

and save the file as 404.php .

Step 2: Upload the custom 404 page to your site

Next, FTP or use the GoDaddy File Manager to put this file in the root of your GoDaddy installation. If you use multiple domains, you can put them in the root of those individual domain folders.

Step 3: Change the GoDaddy 404 Error Behavior

Now go into the GoDaddy Hosting Control Panel, and go under settings. Open the “404 Error Behavior” and then set it to “Use a custom error page”, and then put 404.php in the text box.
Now all you have to do is wait like 5-30 minutes (depending on how busy GoDaddy’s servers are) for GoDaddy to update the 404 behavior for your site, and you should be set. Go ahead and type in some invalid url (i.e. – http://www.omegaprojex.com/kbegjbwgjb ) and you should see your 404 page come up all nice and templated.

Step 4 (optional): Customize your 404 template page

If you want to customize the error message giving by your 404 template (this is normally done by your template) you can just go into your WordPress admin site, go to appearance–>editor and change your 404.php template to say whatever you want. Be careful though – you need to know a little html to do this part; you may want to make a backup of the text that’s in there and experiment a bit if you are unsure how to change the text.

Troubleshooting

Note that although this will force WordPress to load the 404 page designated for your template, in some templates the 404 page may not be specified, so if this doesn’t work right for you, you might want to go check in appearance–>editor inside the WordPress Admin Console and make sure you have a 404.php page. If you don’t there are hundreds of web sites out there that tell you how to make one – so many that I don’t feel it’s necessary to repeat it here.

In any case, this is an extremely dirty hack; after all it doesn’t even really using the confines of the WordPress application to do this. It does work however, and I don’t really see much in the way of an alternative unless GoDaddy changes how the 404 behavior logic works. Given GoDaddy’s “support” record on stuff like this, I doubt that will ever happen.

Categories
Computer Troubleshooting
Tags
WordPress
Comments rss
Comments rss
Trackback
Trackback

« Encrypting Web.Config connection strings with ASP.NET 2.0 Look out for Nazi Zombies! »

2 Responses to “How to make WordPress display a 404 page with GoDaddy hosting”

  1. Wes says:
    April 11, 2009 at 10:14 pm

    Thanks a ton!! Worked like a charm. Perfect step by step write up.

  2. detoxtech says:
    October 6, 2009 at 3:32 am

    i have several websites hosted at Godaddy and i am pretty much satisfied with this domain name registrar. it is also very easy to get coupon codes for Godaddy.

Leave a Reply

Click here to cancel reply.

Categories

  • Anime
    (8)
  • Computer Troubleshooting
    (24)
  • Games
    (17)
  • Family and Everyday Life
    (25)
  • Misc Thoughts
    (13)

Search

Archives

  • June 2010 (2)
  • May 2010 (7)
  • April 2010 (1)
  • January 2010 (1)
  • November 2009 (1)
  • July 2009 (1)
  • May 2009 (1)
  • April 2009 (3)
  • March 2009 (5)
  • February 2009 (8)
  • January 2009 (11)
  • December 2008 (12)
  • November 2008 (12)
  • October 2008 (11)
  • September 2008 (8)

Tags

Apple ASP.NET Blizzard Cisco coding computer repair Disney ecchi Ethan Exchange firewall Food Fort Myers FPS furniture hacking iis 7 jokes Kaden linux Logan Madelyn movies networking Racing RTS SEO Server Administration Shonen SQL SSRS 2005 StarCraft II Warcraft III Windows Server 2008 WordPress Zoo
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox Admin Login