Manual:Short URL/IIS8.5

From MediaWiki.org
Jump to: navigation, search
Translate this page; This page contains changes which are not marked for translation.

Other languages:
English • ‎español • ‎日本語 • ‎中文

This article will walk through the settings necessary to get Short URLs working on Windows Server 2012, IIS 8.5, MediaWiki 1.26, and PHP 5.6.

Prerequisite check[edit]

Ensure that your MediaWiki site is running and accessible at a URL other than /wiki. For this example, we will assume it's running at /w. This means that you can browse, edit articles, etc. on your wiki by starting with http://www.mysite.com/w/index.php?title=Main_Page.

Modify LocalSettings.php[edit]

Edit the appropriate path configurations in your LocalSettings.php file:

$wgScriptPath = "/w";        # may already exist
$wgArticlePath = "/wiki/$1"; # tells MediaWiki how IIS will be rewriting URLs
$wgUsePathInfo = true;

Create a rewrite rule[edit]

Create or edit the web.config file in the site root directory, usually C:\Inetpub\wwwroot (not under /w). Ensure it contains the following:

<?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>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>