Manual:URL Corta/IIS8.5

From mediawiki.org
This page is a translated version of the page Manual:Short URL/IIS8.5 and the translation is 38% complete.

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

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. Esto significa que puedes explorar, editar artículos, etc. en tu wiki empezando con http://www.mysite.com/w/index.php?title=Main_Page.

Modificar LocalSettings.php

Editar las configuraciones de camino apropiadas en tu archivo LocalSettings.php:

$wgScriptPath = "/w";        # ya puede existir
$wgArticlePath = "/wiki/$1"; # tells MediaWiki how IIS will be rewriting URLs
$wgUsePathInfo = true;

Crear una regla reescrita

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

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>