开发者

How do I rewrite / to /blog in IIS 7?

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


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: Link

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜