Archived

Creating a Custom 404 Error/de: Difference between revisions

From Joomla! Documentation

Created page with "==Vier Schritte zur Erstellung einer persönlichen 404-Fehlerseite=="
Created page with "# '''Erstelle einen '404' Artikel ohne Kategoriezuordnung (unkategorisiert)''' #: Erstelle einen Artikel in Joomla! mit der Kategoriezuordnung 'unkategorisiert', welcher als 4..."
Line 5: Line 5:


==Vier Schritte zur Erstellung einer persönlichen 404-Fehlerseite==
==Vier Schritte zur Erstellung einer persönlichen 404-Fehlerseite==
# '''Create an Uncategorized '404' Article'''
# '''Erstelle einen '404' Artikel ohne Kategoriezuordnung (unkategorisiert)'''
#: 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.
#: Erstelle einen Artikel in Joomla! mit der Kategoriezuordnung 'unkategorisiert', welcher als 404 Seite aufgerufen wird. Als Artikel-Text gibst du etwas wie zum Beispiel ''Entschuldige, wir konnten die von Ihnen aufgerufene Seite nicht finden...'' und falls benötigt, außerdem sinvolle Navigations-Links. Zum Beispiel einen Link der zurück zu deiner Startseite führt.
# '''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.

Revision as of 09:41, 5 April 2021

Dieses Tutorial zeigt dir, wie du eine deiner Joomla-Website angepasste 404-Fehlerseite erstellst. Please note, that the approach below sends 200 HTTP code to browser instead of expected 404 (since it finally renders a regular joomla article). The approach tells search engine not to index the page by disallowing it in robots.txt. This doesn't seem to be the best solution.

Vier Schritte zur Erstellung einer persönlichen 404-Fehlerseite

  1. Erstelle einen '404' Artikel ohne Kategoriezuordnung (unkategorisiert)
    Erstelle einen Artikel in Joomla! mit der Kategoriezuordnung 'unkategorisiert', welcher als 404 Seite aufgerufen wird. Als Artikel-Text gibst du etwas wie zum Beispiel Entschuldige, wir konnten die von Ihnen aufgerufene Seite nicht finden... und falls benötigt, außerdem sinvolle Navigations-Links. Zum Beispiel einen Link der zurück zu deiner Startseite führt.
  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

  • 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

More Custom Error Page Information