views:

9

answers:

1

I'm having trouble constructing the correct rewrite rule.

Here's what I need the rule to do:

http://www.mydomain.com/this-is-my-page

http://www.mydomain.com/blog/this-is-my-page

A: 

Do you want to rewrite or redirect? If all you want is redirect, then it is really easy:

<rewrite>
    <rules>
        <rule name="Blog Rule" stopProcessing="true">
            <match url="^this-is-my-page$" />
            <action type="Redirect" url="/blog/this-is-my-page" />
        </rule>
    </rules>
</rewrite>

However, if you want to Rewrite, then you will need to make sure that all links, images, styles, scripts, etc, are linked using the site absolute path (/some-link/ rather than some-link/) or otherwise you are going to have a lot of broken links and styles. You can use URL Rewrite to fix them using Output Rewrite but that is more complicated to get right. I have a sample that shows how to do some of the output rewrite here: http://blogs.msdn.com/b/carlosag/archive/2010/04/02/setting-up-a-reverse-proxy-using-iis-url-rewrite-and-arr.aspx

CarlosAg