[英]IIS7 rewrite for REST not working
I have a REST service and am trying to remove the .svc - a common task/problem. 我有一个REST服务,正在尝试删除.svc-一个常见的任务/问题。
The application on the server is in a virtual directory under the default website (not sure if this is important) 服务器上的应用程序位于默认网站下的虚拟目录中(不确定这是否重要)
I have installed the IIS Rewrite Module and have tried to create a rewrite rule for this. 我已经安装了IIS重写模块,并试图为此创建一个重写规则。
http://blah.me.com/here/thingys/get?id=1111
to rewrite to this: 重写为:
http://blah.me.com/service.svc/thingys/get?id=1111
In my web.conf the following is created: 在我的web.conf中,将创建以下内容:
<rewrite>
<rules>
<rule name="GEAPI /here/ to /service.svc/">
<match url="^(.*?)/here/(.*)$" />
<action type="Rewrite" url="{R:1}/service.svc/{R:2}" />
</rule>
</rules>
</rewrite>
In the GUI the regular expression does test correctly. 在GUI中,正则表达式可以正确测试。
However - when I run this in a browser on the server, it gives the following 404 error: 但是-当我在服务器上的浏览器中运行它时,它出现以下404错误:
Error Code 0x80070002
错误代码0x80070002
Requested URL http://blah.me.com:80/here/thingys/get?id=1111
要求的网址http://blah.me.com:80/here/thingys/get?id=1111
Physical Path C:\\MyApp\\here\\thingys\\get
物理路径C:\\ MyApp \\ here \\ thingys \\ get
C:\\Myapp is the correct physical directory the virtual directory in IIS is pointing to. C:\\ Myapp是IIS中虚拟目录指向的正确物理目录。
Is there something I am missing here ? 我在这里缺少什么吗? I have tried creating this rule under both the default website and the app, both separately and together.
我曾尝试在默认网站和应用程序下分别或一起创建此规则。
Big thanks 太谢谢了
P P
You could use this: 您可以使用此:
<rewrite>
<rules>
<rule name="GEAPI /here/ to /service.svc/">
<match url="^(.*)here(/.+)" />
<action type="Rewrite" url="{R:1}service.svc{R:2}" />
</rule>
</rules>
</rewrite>
IIS will only give you the part of the URI that's after http://blah.me.com/ IIS只给您http://blah.me.com/之后的URI部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.