PDA

View Full Version : Custom 404 Page Not Found tip


hamesh
12-16-2006, 04:10 AM
Quick tip if you hate the default 'Page Not Found' page. Assumes you are using one of the Search plugins and Use Friendly URLs is enabled:

Create a new plugin named Page Not Found. Doesn't matter under what category. Home or Search or blank. Enter whatever text you like in the body. Something like 'The page you are looking for is gone or moved. Try searching for it instead.'.
Create a new category named Page Not Found, page-not-found, do not show in menu, and then adjust skin layout as you like. Select your new Page Not Found plugin and Search plugin in skin layout.
Now the fun part. Open your SD /index.php file in notepad or other text editor and search for page_not_found. Around line 96 in SD 2.40, you should see:

PrintMessage($sdlanguage['page_not_found'] . '<br /><br /><a href="' . $sdurl . '">' . $sdlanguage['redirect_to_homepage'] . '</a>');
Comment this out by placing a pound sign in front of it and then below it, add this new line (substitue your domain obviously):

header("Location: http://www.yourdomain.com/page-not-found"); /* Redirect browser */
Save, reupload and be happy.

Now if google or a person follows an old link, instead of getting the default 'Page Not Found' page with nothing on it, they'll get a fully skinned page with content, options to search, whatever custom message you enter; whatever you want to show them. Plus, passes 302 header. Simple, plus gives search engines something to index, links to follow - get the picture?

Compare these two bogus URLs:

http://www.subdreamer.org/iwantfreebeer
http://www.belchfire.net/iwantfreebeer

If not using Friendly URLs, try this (http://www.subdreamer.com/forum/showthread.php?p=49272#post49272) instead.

Sweet eh? And little effort required. Hey SD dev team - maybe add custom error pages to SD 3 hmm?

Usurper
12-16-2006, 06:57 AM
Clever. :)

RandomNinjaAtk
12-16-2006, 03:12 PM
Wow, nice that is clever, I'm soon gonna work on some admin mods, to enable the ability to get to the forums admin from within sd admin panel.

This way its just feels like one admin panel...

It will mostly invlove adding a new link to the menu for for admin and it will display the page in the right.

I already know how im gonna work it in, just need to figure out how.

Pringles
12-18-2006, 11:28 AM
very neat :)
Thanks for sharing

IGGY
12-18-2006, 06:09 PM
You can also use htaccess file. Then I just used normal SD pages: http://ninepx.com/404