Using ISAPI Rewrite to redirect to

My employer’s SharePoint-powered external website – which I look after – uses ISAPI Rewrite to provide “friendly” URLs for certain pages, and also to redirect old URLs to their new locations. Coming from a LAMP background, this is great for me as it basically works the same as Apache’s mod_rewrite.

Previously the website responded to requests for both and, which is not ideal. SEO best practice is to either redirect the non-WWW version to the WWW version, or vice-versa. In my case, is the preferred format, so I’m using the following rule:

### Redirect to
RewriteCond Host: ^domain\.com
RewriteRule (.*) http\://www\.domain\.com$1 [I,RP]

If you want to do the opposite, you’ll need this one:

### Redirect to
RewriteCond Host: ^www\.domain\.com
RewriteRule (.*) http\://domain\.com$1 [I,RP]
If you enjoyed this post, please share it!

    5 comments on “Using ISAPI Rewrite to redirect to

    1. Wayne says:

      This is exactly what i am looking for. Where should i place this code?

    2. Chris Barnes says:

      Hi Wayne, once you’ve installed ISAPI_Rewrite you just need to put the code into its config file. Does that make sense?

    3. Hello Chris,

      Would it be possible for you to provide an example httpd.ini file so I can see how you have set this up. I am new to ISAPI and have no idea where to start with redirects etc. Any advice would be greatly appreciated.

    4. Chris Barnes says:

      Hi Richard,

      I don’t work on IIS any more so I’m afraid I don’t have an example httpd.ini file to hand, sorry!

    5. No worries. Thanks for the reply though. :-)

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>