[英]Rewrite URL in IIS7 .NET MVC
I'm trying to rewrite the url: 我正在尝试重写网址:
https://mydomain/phone-append https:// mydomain / phone-append
to 至
https://mydomain/Service/PhoneAppend https:// mydomain / Service / PhoneAppend
using the following rule: 使用以下规则:
<rewrite>
<rules>
<rule name="Phone Append">
<match url="phone-append" />
<action type="Rewrite" url="/Services/Index" appendQueryString="true" />
</rule>
</rules>
</rewrite>
The rule works fine if the rewrite url is /Services but when I change it to /Services/PhoneAppend I get a page not found error. 如果重写URL为/ Services,则该规则工作正常,但是当我将其更改为/ Services / PhoneAppend时,出现页面未找到错误。 I've been pulling my hair out for a couple hours. 我已经把头发拉了两个小时了。 Any ideas? 有任何想法吗?
Thanks, Chris 谢谢克里斯
I would recommend using Failed Request Tracing to troubleshoot the failure: http://learn.iis.net/page.aspx/467/using-failed-request-tracing-to-trace-rewrite-rules/ 我建议使用失败的请求跟踪来对失败进行故障排除: http : //learn.iis.net/page.aspx/467/using-failed-request-tracing-to-trace-rewrite-rules/
I cant see why it would not work, the rule above says that it will match (using Regular Expressions) any URL that contains phone-append on it, and rewrite to /Services/Index passing the query string. 我看不到为什么它不起作用,上面的规则说,它将匹配(使用正则表达式)任何包含电话附加的URL,并通过查询字符串重写为/ Services / Index。
If you use Failed Request TRacing you will see the details of the rewrite. 如果使用失败的请求跟踪,您将看到重写的详细信息。
finally if you cant figure it out, URL Rewrite team answers a lot of questions at forums.iis.net 最后,如果您无法解决问题,URL Rewrite团队会在forums.iis.net上回答很多问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.