IIS7 auto rewrites when no trailing slash found

瘦欲@ 提交于 2019-12-11 16:07:23

问题


when I don't have a trailing slash IIS7 automatically does a redirect, how do I fix this..

so http://mydomain.com/deals will redirect to http://mydomain.com/deals/


回答1:


First of all you'll need to install the URL Rewrite Module.

Then create a rule like this:

<rule name="AddTrailingSlashRule" stopProcessing="true">
    <match url="(.*[^/])$"/>
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
    </conditions>
    <action type="Redirect" url="{R:1}/" logRewrittenUrl="true"/>
</rule>


来源:https://stackoverflow.com/questions/10159359/iis7-auto-rewrites-when-no-trailing-slash-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!