Question

A friend is having me figure out a way to modrewrite on his windows server. He is running IIS 6 and Isapi is about the only thing I can find. I am not familiar with it and have read some of the documentation, but can't quite wrap my head around it. He is wanting to rewrite these URLS to make them clean

www.domain.com/cat.php?CTGID=####

and

www.domain.com/pp.php?ID=##

How would I go about rewriting these two URLS to make them Clean in ISAPI. I have installed it on the Windows Server and do I put these rules in IISF.ini in his website folder or put these codes in the master IISF file? Any Help would be greatly appreciated!

Was it helpful?

Solution

Rewrite rules go in a web.config file or in the ApplicationHost.config. As described in http://learn.iis.net/page.aspx/465/url-rewrite-module-configuration-reference/

Examples

<rewrite>
<rules>

    <rule name="Force WWW" stopProcessing="true"> 
        <match url=".*" /> 
        <conditions> 
            <add input="{HTTP_HOST}" pattern="^example.com$" /> 
        </conditions> 
        <action type="Redirect" url="http://www.example.com/{R:0}" redirectType="Permanent" /> 
    </rule> 

    <rule name="Redirect from blog">
      <match url="^blog/([_0-9a-z-]+)/([0-9]+)" />
      <action type="Redirect" url="article/{R:2}/{R:1}" redirectType="Found" />
    </rule>

    <rule name="Rewrite to article.aspx">
      <match url="^article/([0-9]+)/([_0-9a-z-]+)" />
      <action type="Rewrite" url="article.aspx?id={R:1}&amp;title={R:2}" />
    </rule>

</rules>
</rewrite>

OTHER TIPS

For IIS, if the ISAPI_Rewrite module is installed, $_SERVER["IIS_UrlRewriteModule"] is set and contains the version number of the module. So you can check for the existence of this server variable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top