简体   繁体   English

我的重写规则给了我500。怎么了?

[英]My rewrite rule give me a 500. What is wrong?

When I add a new rule to Web.config I get a HTTP 500 error. 将新规则添加到Web.config时,出现HTTP 500错误。 I'm on Azure. 我在Azure上。

The following give an error message: 以下给出错误信息:

<rule name="Rewrite ticket and segment" stopProcessing="true">
    <match url="^([A-Z]{3}[0-9]{4}[A-Z]{1}[0-9]{4})\/([0-9]{1,5})\/?" />
    <action type="Rewrite" url="/api/getTicket.php?ticketId={R:1}&segment={R:2}" />
</rule>

but this one it working : 但这一工作

<rule name="Rewrite ticket" stopProcessing="true">
    <match url="^([A-Z]{3}[0-9]{4}[A-Z]{1}[0-9]{4})\/?" />
    <action type="Rewrite" url="/api/getTicket.php?ticketId={R:1}" />
</rule>

The Reason is, you have invalid XML . 原因是,您的XML无效。 Since web.config is XML based & is not that what you think. 由于web.config是基于XML&所以您就不会这么想了。

Change the & to &amp; &更改为&amp; and it will work. 它会工作。

<rule name="Rewrite ticket and segment" stopProcessing="true">
    <match url="^([A-Z]{3}[0-9]{4}[A-Z]{1}[0-9]{4})\/([0-9]{1,5})\/?" />
    <action type="Rewrite" url="/api/getTicket.php?ticketId={R:1}&amp;segment={R:2}" />
</rule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM