虚拟 url 中的 urlrewritING.net 查询字符导致重定向循环
我有一个项目,我们正在为客户重新构建一个网站,新网站在 .net 平台上使用 umbraco。旧站点是冷聚变。
Umbraco 利用 urlrewriting.net 库,因此我为旧的冷聚变 url 创建了所有 301 个重复规则,但这一个导致了无限循环。
<add name="r66" virtualUrl="^~/thing_info/index.cfm.D413249D-BCD8-304B-02CD-561DAC70641E$"
destinationUrl="~/about-us/award-winning-product" redirect="Application" redirectMode="Permanent" ignoreCase="true" />
我知道 ”。”有特殊含义,但效果很好,我也用过“。”匹配包括“?”在内的任何字符查询字符串的开头字符。 如果我访问尝试不带查询字符串的网址,
http://staging.site/thing_info/index.cfm-D413249D-BCD8-304B-02CD-561DAC70641E
那么我会正确重定向到
http://staging.site/about-us/award-winning-product
但是,如果我尝试该网址(问号是唯一的区别),
http://staging.site/thing_info/index.cfm?D413249D-BCD8-304B-02CD-561DAC70641E
那么我最终会陷入到自身的重定向循环中。 (我检查了响应头)
有谁知道我是否做错了什么或者它是否是 urlrewriting.net 库中的错误?或者如何纠正这个问题?
I've got a project where we're re-building a site for a client, the new site is using umbraco on the .net platform. the old site was cold fusion.
Umbraco utilises the urlrewriting.net library so I created all the 301 recirect rules for the old cold fusions urls but this one is causing an infinite loop.
<add name="r66" virtualUrl="^~/thing_info/index.cfm.D413249D-BCD8-304B-02CD-561DAC70641E$"
destinationUrl="~/about-us/award-winning-product" redirect="Application" redirectMode="Permanent" ignoreCase="true" />
I know "." has a special meaning but it works well enough, also I've used "." to match any character including the "?" character beginning the query string.
if I visit try the url without a querystring like so
http://staging.site/thing_info/index.cfm-D413249D-BCD8-304B-02CD-561DAC70641E
then I get redirected correctly to
http://staging.site/about-us/award-winning-product
However if I try the url (question mark is the only difference)
http://staging.site/thing_info/index.cfm?D413249D-BCD8-304B-02CD-561DAC70641E
Then I end up in a redirect loop to itself. (I checked the response header)
Does anyone have any idea if I've done something wrong or if it's a bug in the urlrewriting.net library? or how to correct the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
默认情况下,UrlRewritingNet 不会在模式匹配中包含查询字符串。要启用此功能,您需要添加以下属性rewriteUrlParameter="IncludeQueryStringForRewrite"
尝试一下,让我知道它是否有效。
乔纳森
By default UrlRewritingNet will not include the querystring in the pattern match. to enable this you need to add the following attribute rewriteUrlParameter="IncludeQueryStringForRewrite"
Give this a try and let me know if it works.
Jonathan
它是一个正则表达式,因此 .表示任何字符。您可以尝试使用 转义点。或者带有 \? 的问题?专门匹配该字符。
Its a regular expression so the . means any character. You could try escaping the dot with . or the question with \? to match that character specifically.
当我尝试使用 umbraco 和 UrlRewritingNet 进行永久 301 重定向时,我遇到了同样的问题。
读完这篇文章和一些头发拉扯后,我得到了它与 umbraco/config/urlrewriting.config 中的以下条目一起工作
这是乔纳森的答案的组合,添加 rewriteUrlParameter="IncludeQueryStringForRewrite" ,并转义 virtualUrl参数正确,解决了这个问题。
I had the same problem when trying to do a permanent 301 redirect using umbraco and UrlRewritingNet.
After reading this and some hair pulling I got it working with the following entry in umbraco/config/urlrewriting.config
It was the combination of Jonathan's answer, to add rewriteUrlParameter="IncludeQueryStringForRewrite", and escaping the virtualUrl parameter correctly that sorted it out.