简体   繁体   English

IIS url仅在url具有子文件夹的地方重写

[英]IIS url-rewrite only where url has sub-folder

I need to create a URL re-write/redirect rule in IIS that should only redirect requests that are for the home page of the site. 我需要在IIS中创建URL重写/重定向规则,该规则应仅重定向针对网站主页的请求。 Pages that are in sub-folders should not be redirected (we are rewriting to a different URL for mobile devices to a mobile specific site, but only for the home page. Sub-folders still need to go to the desktop version of the site.) 子文件夹中的页面不应重定向(我们正在将移动设备的其他URL重写为特定于移动设备的站点的URL,而仅将其重写为主页。子文件夹仍需要转到该站点的桌面版本。 )

For example: http://my.site.com or my.site.com should redirect http://my.site.com/pages/page1.aspx and my.site.com/pages/page2.aspx should not 例如: http ://my.site.com或my.site.com应该重定向http://my.site.com/pages/page1.aspx,而my.site.com/pages/page2.aspx不应

I have tried variations on just looking for a url that contains a '/', which work, but then if the url contains 'http://' it still matches the rule. 我已经尝试过寻找仅包含'/'的url的变体,但可以,但是如果url包含'http://'的话,它仍然与规则匹配。

This rule will redirect only homepage to /pages/page1.aspx 此规则将将主页重定向到/pages/page1.aspx

<rules>
    <rule name="Redirect home to /pages/page1.aspx" stopProcessing="true">
        <match url="^$" />
        <action type="Redirect" url="/pages/page1.aspx" />
    </rule>
</rules>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM