IIS7 上的 URL 重写
我正在尝试使用 IIS 上的入站规则将 URL 重写为另一个 URL。我想做的基本上是任何类似于 localhost/Membership/Login 的请求都将是 localhost/handlers/mapper.ashx?url=Membership/Login 。我所做的是创建一个如下所示的模式
(Membership\/)(.+)
,重写网址
http://localhost/handlers/mapper.ashx?url={R:0}
实际上是这种方式并没有给我我想要的解决方案。它会像正常请求一样继续工作,不会发送到mapper.ashx。
可能是什么问题?做这样的事情的正确方法是什么?
提前致谢,
I am trying to rewrite a url to a different one by using inbound rule on IIS. What I am trying to do is basically any request thats like localhost/Membership/Login
will be localhost/handlers/mapper.ashx?url=Membership/Login
. What I have done is creating a pattern something like below
(Membership\/)(.+)
and the rewrite url is
http://localhost/handlers/mapper.ashx?url={R:0}
Actually this way did not give me the solution what I want. It keeps working as a normal request not goes to the mapper.ashx.
What can be the problem ? What is the proper way to do something like that ?
Thanks in advance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如达拉斯已经指出的那样,你要求的东西不是你自己的解决方案所建议的。但我会给你两种选择。首先,如果您只需要 URL 的
login
部分作为处理程序的methodname
参数,则可以使用以下重写规则:如果您需要完整的 URL作为您自己的解决方案建议的
url
参数,那么您可以使用以下重写规则:As Dallas already pointed out you ask for something else than what your own solutions suggests. But I will give you both options. First of all, if you just need the
login
part of the URL as amethodname
parameter for your handler you can use the following rewrite rule:If you need the complete URL in the
url
parameter as your own solution suggests then you can use the following rewrite rule:这并不能解释为什么您的映射被跳过,但您的示例和实际实现是不同的。您说您希望将请求映射到
localhost/handlers/mapper.ashx?methodname=Login
但您的重写网址示例是
http://localhost/handlers/mapper.ashx?url={R:0}
您的重写网址中有网址,而不是方法名
This doesn't explain why your mapping is being skipped but your example and actual implementation are different. You say you want the requests mapped to
localhost/handlers/mapper.ashx?methodname=Login
but your example for rewrite url is
http://localhost/handlers/mapper.ashx?url={R:0}
You have url in your rewrite url, not methodname