Manual:Short URL/Page title -- Windows & Apache without 403 on Special Pages

From MediaWiki.org
Jump to: navigation, search

Because the colon character is used by NTFS to denote symbolic links, when http://example.com/Special:SpecialPages is accessed, Windows looks for a non-existent symbolic link in the document root for example.com. This generates a 403 error.

Including an .htaccess file in the document root does not resolve the problem because the error occurs before the .htaccess file is parsed. To prevent the error from occurring, the colon character must be addressed in an appropriate .conf file.

Step 1[edit | edit source]

If you have vHosts configured, insert the following Rewrite directives into the appropriate <VirtualHost> directive. Otherwise, insert it in the <directory> directive for your wiki's root directory:

RewriteEngine On
RewriteRule ^/(.*):(.*) /index.php/$1:$2

Step 2[edit | edit source]

Edit your LocalSettings.php file to include:

$wgArticlePath = "/$1";

Notice[edit | edit source]

It should be noted that this method of Pretty URLs is not currently compatible with pretty action URLs (e.g. /action/edit/Main_page). MediaWiki assumes that anything in the path (aside from the domain) is a page title, causing a recursion loop that results in attempts to edit /Main_page instead creating a new page named /action/edit/Main_Page. This issue is confirmed in v.1.15.1.

Step 3[edit | edit source]

Add these rules to the .htaccess file in your root directory.

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?title=$1 [L,QSA]

Conclusion[edit | edit source]

The rewrite rules in the .conf file invisibly translates http://example.com/Special:SpecialPage to http://example.com/index.php/Special:SpecialPage. Then the .htaccess file translates it back to http://example.com/Special:SpecialPage for processing.