【发布时间】:2013-11-10 12:37:04
【问题描述】:
我有一个 asp.net mvc 4 应用程序,我在 web.config 中有这个规则
<system.webServer>
<rewrite>
<rules>
<rule name="Remove Virtual Directory">
<match url=".*" />
<action type="Rewrite" url="{R:0}" />
</rule>
</rules>
</rewrite>
我不明白这是为什么以及如何工作的。我使用它是因为 godaddy 在 url 中添加了一个虚拟路径,其中包含应用程序所在文件夹的名称。
即example.com/foldername/index 变为example.com/index
那么它是如何通过“.*”找到虚拟路径并删除的。 {R:0} 是什么? 谢谢。
【问题讨论】:
-
此规则是否在不在服务器根目录中的
web.config中? -
@cheesemacfly 它不在服务器的根目录中。它在一个文件夹中。 Web 应用程序在哪里。网络配置位于应用程序的根目录中。
标签: asp.net asp.net-mvc url-rewriting asp.net-mvc-routing