URL rewrite is producing 404

半世苍凉 提交于 2019-12-12 05:26:45

问题


I'm trying to rewrite office.domain.com/app1 requests to server3:81 using the rule below, but I'm getting a 404. I can browse to server3:81 just fine.

The Failed Request Tracing logs are available here, but they don't seem to reveal much.

I've also tried url="http://server3:81/{R:0}" and url="http://server3:81/{R:1}" (not sure why/what the difference is), but both produce the same result (404).

What am I doing wrong in my rule? (Warning: I'm pretty unhandy with RegEx just yet, but I'll do my best to understand your answer. I may have to ask for clarification.)


<rule name="App1" stopProcessing="true">
  <match url="^app1" />
  <action type="Rewrite" url="http://server3:81/" />
</rule>

回答1:


There's a couple of things you might want to try, the first would be to change the regex pattern to match the entire url you are replacing and capture the part you want to keep. The second suggestion would be to verify that your rewrite url is http and not https:

Method One: (regex change)

<rule name="App1" stopProcessing="true">
 <match url="^.*/(app1)" />
   <action type="Rewrite" url="http://server3:81/{R:1}" />
</rule>

Method Two: (regex + https + port change)

<rule name="App1" stopProcessing="true">
 <match url="^.*/(app1)" />
   <action type="Rewrite" url="https://server3:8080/{R:1}" />
</rule>

Method Three: (regex full url + relative rewrite)

<rule name="App1" stopProcessing="true">
 <match url=".*" />
   <action type="Rewrite" url="server3:81/app1" />
</rule>


来源:https://stackoverflow.com/questions/34747093/url-rewrite-is-producing-404

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!