小编fse*_*rio的帖子

IIS Forces甚至使用URL Rewrite删除它

即使使用以下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)

任何帮助都会受到欢迎

iis-7 url-rewriting trailing-slash

7
推荐指数
1
解决办法
9222
查看次数

URL 重写问题 - 规则用作重定向,但不能用作重写

我一直试图弄清楚为什么这个规则作为重定向而不是重写。直到几个小时后我才想到尝试将其作为重定向,令我惊讶的是它起作用了。

你能解释一下为什么第一个有效但第二个无效吗?

重定向

<rule name="Rewrite to images.cdn.com" enabled="true">
<match url="^images/(.+)$" />
<action type="Redirect" url="http://images.cdn.com/{R:1}"/>
</rule>
Run Code Online (Sandbox Code Playgroud)

改写

<rule name="Rewrite to images.cdn.com" enabled="true">
<match url="^images/(.+)$" />
<action type="Rewrite" url="http://images.cdn.com/{R:1}"/>
</rule>
Run Code Online (Sandbox Code Playgroud)

失败的请求日志信息 替换和重写是相同的,这意味着它应该可以工作,因为您可以将该 URL 复制到浏览器中,它就会工作。

<EventData>
  <Data Name="ContextId">{00000000-0000-0000-6C00-0080000000F8}</Data>
  <Data Name="Substitution">http://39e403d64323deb9e704-7fcaccb4b31037dfec2feb2a157f55bc.r52.cf1.rackcdn.com/images/updateprogress.gif</Data>
  <Data Name="RewriteURL">http://39e403d64323deb9e704-7fcaccb4b31037dfec2feb2a157f55bc.r52.cf1.rackcdn.com/images/updateprogress.gif</Data>
  <Data Name="AppendQueryString">false</Data>
  <Data Name="LogRewrittenURL">false</Data>
 </EventData>
Run Code Online (Sandbox Code Playgroud)

谢谢你!

ASP.NET/IIS 7.0

redirect cdn url-rewriting

5
推荐指数
1
解决办法
2889
查看次数

标签 统计

url-rewriting ×2

cdn ×1

iis-7 ×1

redirect ×1

trailing-slash ×1