Manual:Short URL/IIS8.5

Jump to navigation Jump to search
Other languages:

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

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"?>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                    <match url="^wiki/([^/]+/?[^/]*/?[^/]*)/?$" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <action type="Rewrite" url="w/index.php?title={R:1}" logRewrittenUrl="true" />

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.

            <rule name="RootHitRedirect" stopProcessing="true">
                <match url="^$" />
                <action type="Redirect" url="/w/" />