Extension:Special404
This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. If you are interested in taking on the task of developing and maintaining this extension, you can request repository ownership. As a courtesy, you may want to contact the author. You should also remove this template and list yourself as maintaining the extension in the page's {{Extension }} infobox. |
Special404 Release status: unmaintained |
|
---|---|
Implementation | Special page |
Description | Provides a simple wiki based 404 special page destination |
Author(s) | Daniel Friesen (Dantmantalk) |
MediaWiki | 1.25+ |
PHP | 5.3+ |
Database changes | No |
License | GNU General Public License 2.0 or later |
Download | README |
$egSpecial404RedirectExistingRoots |
|
Quarterly downloads | 1 (Ranked 135th) |
Translate the Special404 extension if it is available at translatewiki.net | |
The Special404 extension 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
[edit]- Download and move the extracted
Special404
folder to yourextensions/
directory.
Developers and code contributors should install the extension from Git instead, using:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Special404 - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'Special404' );
- 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.
- Done â Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Web server configuration
[edit]Since this is a 404 handler your webserver will need a little configuration to get it working.
Apache
[edit]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.
This rewrite rule is not canonical of cause. For example if you use RewriteBase /
rule and your MediaWiki is placed at /w
directory (the most usual case) then, the rule will look like this:
RewriteBase /
# ... your other rules ...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?.*$ w/index.php?title=Special:Error404
IIS
[edit]Use the following web.config in the directory containing /w
(do not put it inside /w
), and change wiki.example.com to your domain name.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<outboundRules>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
<rules>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="^wiki/([^/]+/?[^/]*/?[^/]*)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="w/index.php?title={R:1}" logRewrittenUrl="true" />
</rule>
<rule name="RootHitRedirect" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/w/" />
</rule>
<rule name="Fix Old Style URLs">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^wiki.example.com$" />
<add input="{PATH_INFO}" pattern="^/wiki/" negate="true" />
<add input="{PATH_INFO}" pattern="^/w/" negate="true" />
</conditions>
<action type="Rewrite" url="\w\index.php?title=Special:Error404" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The rule in question that makes this extension work for IIS is Fix Old Style URLs
. See this page for more details on how these rules were formulated.
Short URLs
[edit]If your pages are located at the root directory of your wiki (e.g.: example.com/Page_name), there's no point in installing this extension, because every unknown path of your site will reach MediaWiki, either an existing page, or a non-existing one.
You can edit MediaWiki:noarticletext and MediaWiki:noarticletext-nopermission to customize the text displayed on the non-existing page.
This extension is included in the following wiki farms/hosts and/or packages: This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |