网址重写www和非www

时间:2013-03-05 11:15:18

标签: iis-7 url-rewriting

我在IIS中有一些规则可以将传入的请求重定向到具有文件扩展名的页面,因此例如mysite.com/hello/会定向到www.mysite.com/hello.aspx

我有一条适合尾随斜线的规则,所以我最终没有www.mysite.com/hello/.aspx

这很好,但它不适用于以www开头的请求 所以,www.mysite.com / hello保持不变

我尝试为符合模式www *的任何内容添加额外的规则,但似乎不起作用。

任何建议非常感谢

<rule name="Remove trailing slash" stopProcessing="false">
                <match url="(.*)/$" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="{R:1}" />
            </rule>
            <rule name="AddASPX" enabled="true">
                <match url=".*" negate="false" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
                </conditions>
                <action type="Rewrite" url="{R:0}.aspx" />
            </rule>

0 个答案:

没有答案