Jump to content

Extension:Special404: Difference between revisions

From mediawiki.org
Content deleted Content added
G.Hagedorn (talk | contribs)
m This extension appears to be in SVN, not Git.
Line 8: Line 8:
|version = 1.1
|version = 1.1
|license = GPL2+
|license = GPL2+
|download = {{WikimediaDownload|Special404}}
|download = {{WikimediaDownload|Special404}}
}}
}}



Revision as of 22:48, 13 August 2012

MediaWiki extensions manual
Special404
Release status: beta
Implementation Special page
Description Provides a simple wiki based 404 special page destination
Author(s) Daniel Friesen (Dantmantalk)
Latest version 1.1
MediaWiki >= 1.31.0
License GPL2
Download Template:WikimediaDownload/svn
Quarterly downloads 3 (Ranked 131st)
Translate the Special404 extension if it is available at translatewiki.net

Special404 provides a simple wiki based 404 special page destination you can configure for your wiki. The body of the 404 page can also be customized using MediaWiki:Special404-body on your wiki.

Installation

  1. Download a snapshot and extract it to your extensions directory. Choose the version that matches your version of MediaWiki.
  2. Add
    require_once( "$IP/extensions/Special404/Special404.php" );
    
    to the bottom of LocalSettings.php.
  3. Initial installation can now be verified through Special:Version of your wiki.
  4. Add some webserver config to redirect 404s to the special page, usually this is in the form of a .htaccess config, more information in the section below or in the extension's README.

WebServer Config

Since this is a 404 handler your webserver will need a little configuration to get it working.

Apache

Using an ErrorDocument doesn't seem to work in apache, whatever the destination you set, Apache seems to direct to something that MediaWiki interprets normally instead of as a request to display the special page, so we use a rewrite rule instead. You can place the following in your .htaccess file to make the extension work. Be sure to tweak the path to index.php to match the proper path to yours. Also make sure that this is the last rewrite rule, you do not want any rewrite rules after this one they will likely be overridden.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?.*$ /index.php?title=Special:Error404

Keep in mind that it's important that you use /index.php?title=Special:Error404 (with the proper path to index.php of course) and not something like /wiki/Special:Error404 as using the latter causes MediaWiki to treat it normally and direct you to the main page instead of displaying the 404 page.