Reescritura de URL para Windows Server (IIS)

Reescritura de URL para Windows Server (IIS)

Ayer pedí ayudareescritura de URL- Ulrich Palha me ayudó a solucionar el problema.

Su solución funciona muy bien en un servidor Linux usando .htaccess, y agradezco su ayuda, pero la solución no funciona en un servidor Windows que ejecuta IIS. Pasé todo el día haciendo lo mejor que pude para que funcionara en un servidor Windows, pero fue un mal día para mí :-(, así que pido ayuda.

Aquí hay un código que funciona en Linux usando.htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]*)/?([^/]*)/?([^/]*)\.html$ category.php?maincat_url=$1&first_subcat_url=$2&second_subcat_url=$3 [L]

Gracias.

Respuesta1

Necesitas instalar gratisMódulo de reescritura de URLde Microsoft. Luego debes agregar la siguiente regla de reescritura a tu archivo web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Test" stopProcessing="true">
                    <match url="^([^/]*)/?([^/]*)/?([^/]*)\.html$" />
                    <action type="Rewrite" url="category.php?maincat_url={UrlEncode:{R:1}}&amp;first_subcat_url={UrlEncode:{R:2}}&amp;second_subcat_url={UrlEncode:{R:3}}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

información relacionada