简体   繁体   中英

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. I'm on 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 . Since web.config is XML based & is not that what you think.

Change the & to &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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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