[英]How does the rewrite works in web.config system.webserver
I have an asp.net mvc 4 application and i have this rule in web.config 我有一个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>
I can't understand why and how this works. 我不明白为什么以及如何运作。 I use it because godaddy adds a virtual path in the url with the name of the folder the application is in. ie
example.com/foldername/index
becomes example.com/index
我使用它是因为Godaddy在URL中添加了虚拟路径,并带有应用程序所在文件夹的名称。即
example.com/foldername/index
变为example.com/index
So how does it finds the virual path by ".*" and removes it. 那么它如何通过“。*”找到虚拟路径并删除它。 And what {R:0} is?
{R:0}是什么? Thank you.
谢谢。
Well It seems that I the match url this regex matches every url and it doesn't allow to redirect a url that includes the virtual path. 好吧,看来我这个正则表达式的匹配URL匹配每个URL,并且不允许重定向包含虚拟路径的URL。 Since the routing of mvc finds the resource.
由于mvc的路由会找到资源。
As for {R:0}. 至于{R:0}。 The request url is the first argument hence the 0, and the regex is a secont argument not uses.
请求url是第一个参数,因此为0,而regex是未使用的secont参数。 This would be the {R:1}.
这就是{R:1}。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.