Archived

Difference between revisions of "Creating a Custom 404 Error"

From Joomla! Documentation

m (Marked for translation)
(One intermediate revision by one other user not shown)
Line 2: Line 2:
  
 
<translate>
 
<translate>
This tutorial will show you how to create a custom 404 error page for use in your Joomla Webssite.
+
<!--T:1-->
 +
This tutorial will show you how to create a custom 404 error page for use in your Joomla web-site.
 
</translate>
 
</translate>
  
 
<translate>
 
<translate>
== Four Steps to Creating a Custom 404 Error Page ==
+
== Four Steps to Creating a Custom 404 Error Page == <!--T:2-->
 
</translate>
 
</translate>
 
<translate>
 
<translate>
 +
<!--T:3-->
 
# '''Create an Uncategorized '404' Article'''
 
# '''Create an Uncategorized '404' Article'''
 
#: Create an 'uncategorized' article in Joomla! to serve as your 404 Page.  Include some text such as ''Sorry, we could not find the page you were looking for...'' and if necessary, also any useful navigational links.  For example, you may wish to add a link back to your site's home page.
 
#: Create an 'uncategorized' article in Joomla! to serve as your 404 Page.  Include some text such as ''Sorry, we could not find the page you were looking for...'' and if necessary, also any useful navigational links.  For example, you may wish to add a link back to your site's home page.
 
</translate>
 
</translate>
 
<translate>
 
<translate>
 +
<!--T:4-->
 
# '''Create and copy a link to that new 404 Article.'''
 
# '''Create and copy a link to that new 404 Article.'''
 
#: Create a menu item which links to the new 404 Article and 'apply' your changes.  Then copy the URL information (index.php?optio...), set the menu item as 'unpublished' and close out of the menu editing page.  You may want to paste the copied URL into Notepad or somewhere accessible for the time-being.
 
#: Create a menu item which links to the new 404 Article and 'apply' your changes.  Then copy the URL information (index.php?optio...), set the menu item as 'unpublished' and close out of the menu editing page.  You may want to paste the copied URL into Notepad or somewhere accessible for the time-being.
 
</translate>
 
</translate>
 
<translate>
 
<translate>
 +
<!--T:5-->
 
# '''Copy error.php to your Template's Directory'''
 
# '''Copy error.php to your Template's Directory'''
 
#: In your Joomla! installation copy the file error.php from the templates/system directory, to your Template directory.  For example, if I was using a template named 'Cleancloud' I would copy the error.php file to the templates/cleancloud directory.
 
#: In your Joomla! installation copy the file error.php from the templates/system directory, to your Template directory.  For example, if I was using a template named 'Cleancloud' I would copy the error.php file to the templates/cleancloud directory.
 
</translate>
 
</translate>
 
<translate>
 
<translate>
 +
<!--T:6-->
 
# '''Modify error.php to Redirect 404 Errors to your 404 Article  '''  
 
# '''Modify error.php to Redirect 404 Errors to your 404 Article  '''  
 
#: Edit the error.php file as follows, adding the code below immediately under the 'restricted access' line:
 
#: Edit the error.php file as follows, adding the code below immediately under the 'restricted access' line:
Line 34: Line 39:
  
 
<translate>
 
<translate>
 +
<!--T:7-->
 
Replace the location information (index.php?option..) with the URL from the menu item you created.
 
Replace the location information (index.php?option..) with the URL from the menu item you created.
  
 +
<!--T:8-->
 
If you are using Joomla 1.5 and below please use this detection code instead:
 
If you are using Joomla 1.5 and below please use this detection code instead:
 
</translate>
 
</translate>
Line 47: Line 54:
  
 
<translate>
 
<translate>
==Exclude your Custom 404 Error Page from Search Engines==
+
==Exclude your Custom 404 Error Page from Search Engines== <!--T:9-->
 
* In Joomla 3.x: in Article Manager > Edit Article > [Publishing] > set "Robots" to "Noindex".
 
* In Joomla 3.x: in Article Manager > Edit Article > [Publishing] > set "Robots" to "Noindex".
 
* In Joomla 2.5: in Article Manager > Edit Article > [Metadata Options] > set "Robots" to "Noindex".
 
* In Joomla 2.5: in Article Manager > Edit Article > [Metadata Options] > set "Robots" to "Noindex".
Line 55: Line 62:
  
 
<translate>
 
<translate>
== Additional Steps Toward a Better Custom 404 Error Page ==
+
== Additional Steps Toward a Better Custom 404 Error Page == <!--T:10-->
 
* Follow the Best-Practices described here:  http://www.alistapart.com/articles/perfect404/
 
* Follow the Best-Practices described here:  http://www.alistapart.com/articles/perfect404/
 
* Be creative, add a [http://www.geekhaiku.com/tag/404/ 404 Haiku] or maybe an [http://www.smashingmagazine.com/2007/08/17/404-error-pages-reloaded Interesting Photo]
 
* Be creative, add a [http://www.geekhaiku.com/tag/404/ 404 Haiku] or maybe an [http://www.smashingmagazine.com/2007/08/17/404-error-pages-reloaded Interesting Photo]
Line 61: Line 68:
  
 
<translate>
 
<translate>
== More Custom Error Page Information ==
+
== More Custom Error Page Information == <!--T:11-->
 
* [[S:MyLanguage/Custom_error_pages|Custom Error Pages]]
 
* [[S:MyLanguage/Custom_error_pages|Custom Error Pages]]
 
* [[S:MyLanguage/System_error_pages|System Error Pages]]
 
* [[S:MyLanguage/System_error_pages|System Error Pages]]
Line 70: Line 77:
  
 
<translate>
 
<translate>
 +
<!--T:12-->
 
[[Category:Tutorials]]
 
[[Category:Tutorials]]
 
</translate>
 
</translate>

Revision as of 09:01, 25 December 2014

This page has been archived. This page contains information for an unsupported Joomla! version or is no longer relevant. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Other languages:
Deutsch • ‎English • ‎Nederlands • ‎español • ‎français • ‎italiano • ‎русский

This tutorial will show you how to create a custom 404 error page for use in your Joomla web-site.

Four Steps to Creating a Custom 404 Error Page[edit]

  1. Create an Uncategorized '404' Article
    Create an 'uncategorized' article in Joomla! to serve as your 404 Page. Include some text such as Sorry, we could not find the page you were looking for... and if necessary, also any useful navigational links. For example, you may wish to add a link back to your site's home page.
  2. Create and copy a link to that new 404 Article.
    Create a menu item which links to the new 404 Article and 'apply' your changes. Then copy the URL information (index.php?optio...), set the menu item as 'unpublished' and close out of the menu editing page. You may want to paste the copied URL into Notepad or somewhere accessible for the time-being.
  3. Copy error.php to your Template's Directory
    In your Joomla! installation copy the file error.php from the templates/system directory, to your Template directory. For example, if I was using a template named 'Cleancloud' I would copy the error.php file to the templates/cleancloud directory.
  4. Modify error.php to Redirect 404 Errors to your 404 Article
    Edit the error.php file as follows, adding the code below immediately under the 'restricted access' line:

If you are using Joomla 1.6, 1.7, 2.5, or 3.x please use this detection code:

if (($this->error->getCode()) == '404') {
header('Location: /index.php?option=com_content&view=article&id=75');
exit;
}

Replace the location information (index.php?option..) with the URL from the menu item you created.

If you are using Joomla 1.5 and below please use this detection code instead:

if (($this->error->code) == '404') {
header('Location: /index.php?option=com_content&view=article&id=75');
exit;
}

Exclude your Custom 404 Error Page from Search Engines[edit]

  • In Joomla 3.x: in Article Manager > Edit Article > [Publishing] > set "Robots" to "Noindex".
  • In Joomla 2.5: in Article Manager > Edit Article > [Metadata Options] > set "Robots" to "Noindex".
  • In other versions, add the following line to the robots.txt file located in the root directory of your Joomla! installation. Replace the (index.php?option..) location with your 404 Article URL.
    Disallow: /index.php?option=com_content&view=article&id=75

Additional Steps Toward a Better Custom 404 Error Page[edit]

More Custom Error Page Information[edit]