RewriteModule for ASP.NET 2.0

mod_rewrite is one of the most useful module for Apache.

But what to do if I’m on a Windows IIS server? I only googled a few commercial ISAPI modules (ISAPI ReWrite, IIS Rewrite). This is the most painful on Windows platform.

OK. Since I only need a few feature of the rewrite currently. I decided to do it myself. An early version is available from CVS repository – anoncvs without password.

Yeah. The RewriteCond feature haven’t been implemented. Sorry It’s only one afternoon work and I’m still a newbie on ASP.NET platform.

Here’s the sample configuration

<configuration>
    <configsections>
<section
            name="rewriteSection"
            type="Dragonsoft.RewriteConfigurationSection, Dragonsoft.RewriteModule" />
    </configsections>

    <system .web>
        <httpmodules>
            <add name="rewrite" type="Dragonsoft.RewriteModule" />
        </httpmodules>
    </system>

    <rewritesection>
        <![CDATA[
        RewriteRule ^~/news/([^/]+)/([^/]+)\.html$ ~/news.aspx?id=$1&#038;name=$2 [L]
        RewriteRule \fake\(.*).html$ \real\$1.aspx [NC,L]
        ]]&gt;
    </rewritesection>
</configuration>

–update: URL Rewrite Filter for IIS is open source. I haven’t tested it.