即使使用以下URL重写URL,我也无法删除我网站的URL的斜杠:http: //ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/.
真的很沮丧,因为它应该是如此简单,但我的尝试没有产生任何结果.
我甚至创建了一个测试目录并添加了名为desktops.aspx的文件和名为desktops的子文件夹.
没有子目录"/ test/desktops"加载正常,因为我将默认文档设置为查看desktops.aspx.
创建一个子文件夹并仍然引用"/ test/desktops"它会强制斜杠并查看子目录.
为什么IIS会这样做,因为它应该首先查找文件然后查找子目录?服务器端是否有任何设置可以强制撤销斜杠?
URL重写代码段:
<rule name="SEO - Remove trailing slash" stopProcessing="false">
<match url="(.+)/$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_METHOD}" pattern="GET" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="_{R:1}" />
</rule>
Run Code Online (Sandbox Code Playgroud)
任何帮助都会受到欢迎