Manual:Short URL/IIS8.5

From mediawiki.org

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>

Redirect visitor of your domain to your wiki[edit]

Our official guides for short url configuration include recommendations on how to point the root of your site to your wiki using your short url config.

To do this in IIS add the following to your web.config.

<system.webServer>
    <rewrite>
        <rules>
            <rule name="RootHitRedirect" stopProcessing="true">
                <match url="^$" />
                <action type="Redirect" url="/w/" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>