Iis 7 在www和非www上重写Url

Iis 7 在www和非www上重写Url,iis-7,url-rewriting,Iis 7,Url Rewriting,我在IIS中有一些规则可以将传入的请求重定向到具有文件扩展名的页面,例如mysite.com/hello/被定向到www.mysite.com/hello.aspx 我有一条规则,它迎合了后面的斜杠,所以我不会以www.mysite.com/hello/.aspx结束 这很好,但它不适用于以www开头的请求 因此,www.mysite.com/hello保持不变 我尝试为任何与模式匹配的东西添加一条附加规则,但似乎不起作用 非常感谢您的建议 <rule name="Remove trail

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

我有一条规则,它迎合了后面的斜杠,所以我不会以www.mysite.com/hello/.aspx结束

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

我尝试为任何与模式匹配的东西添加一条附加规则,但似乎不起作用

非常感谢您的建议

<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>
2个问题:有什么用?为什么不在第一个规则的操作中使用重定向?