|
This article explains how to use a Joomla! article as a custom 404 Error / Page Not Found page. In other words, when vistitors to your site try to access a url that is not available they will see a custom page that looks exactly the same as the rest of your website. Here is what you have to do: 1. Create a new article page that you want to display for your users when they bump into 404 error. I recommend that you give the visitor some instructions/suggestions as to how they may find the content they are looking for on your website. You can also insert the Search module directly into the content area with the MosModule extension. Here is a link to a page that has collected some very interesting 404 Error Pages!: http://www.smashingmagazine.com/2007/08/17/404-error-pages-reloaded/ 2. Create a file named error.php with the following code: <?php defined( '_JEXEC' ) or die( 'Restricted index access' ); if (($this->error->code) == '404') { header('Location: ' . $this->baseurl . 'path-to-custom-error-page'); exit; }
Note: 'path-to-custom-error-page' is the url of your custom 404 Error Page from the base url of Joomla! Do NOT include a / preceeding the url. For example, if the full url of your custom error page is http://www.yourdomain.com/page-not-found.html you would only use 'page-not-found.html' for the path.
To get the url of your custom error page I create a link to the page from a menu that is not published. You can then use the page alias as the url. (I am using Joomla!'s built-in SEF.) 3. Upload the error.php file that you created to your template folder. (/templates/yourtemplate/) 4. Test to see if it works! Try adding some random text to the end of your domain name in the addres bar of your web browser, press Enter/Return on your keyboard, and see what happens! You should now see your custom error page. Sources: http://docs.joomla.org/Custom_error_pages http://www.joomlarise.com/tutorials-and-tips/3-tips/4-how-to-display-custom-404-error-page-in-joomla-website
|