How to Create a Custom Smart 404 Script
If you're worried about finding a not so nice looking 404 page on your website you can quite easily add a custom 404 page to your site. This page will tell your visitors that the page they are trying to reach doesn't exist and it will also tell them where to find the content they are looking for. This article will teach you how to create a custom 404 script using just PHP and a couple of simple server commands, to pull in related pages along with giving an on site search option!
EditSteps
-
1Make a PHP and CSS file. Name them something like smart404.php and smart404.css and place them in a folder (smart404) for easier editing on a server.Ad
-
2Add some simple HTML code to your PHP file.
-
3Add the PHP code to display custom text depending on how a visitor reaches a 404 page on the site, here's the code for that part.
-
4Try the following code to grab and post relevant pages on the 404 page from the keywords in the URL of that 404 page.
-
5Add a search function to the custom 404 script which can be done in a number of ways either with Google search or a custom search engine.
-
6Go to [www.google.com/cse] and create your own custom search (use the shiny option for a theme/layout if you wish to use my css correctly).
-
7Find the line of code that says: "var customSearchControl = new google.search.CustomSearchControl('012869460898643755040:0jf7icffqma');" as you will need to change the code between () to you unique code.
-
8Now you have all that here's what the code will look like to fully work with your site and custom smart 404:
-
9
-
10== Fully Working Download ==
-
11You can download a fully functional copy of the script from [1]Ad
We could really use your help!
computers?

sabbaticals?

body tricks?

car stereos?

Article Info
Thanks to all authors for creating a page that has been read 3,046 times.
About this wikiHow