使用 urlrewrite 通配符重定向动态无扩展 URL
我有一个动态的“推荐人”列表,例如 ANN、BOB、...、ZED。我希望访问我的网址 www.website.com/ANN、www.website.com/BOB、www.website.com/ZED 的人被定向到一个特殊的动态生成的引荐页面。
我想要做的是设置 URLRewriter 规则 在我的 IIS7 上,它将把任何没有文件扩展名的页面定向到 /reroute.aspx,它将处理生成动态页面。我遇到的问题是正则表达式或通配符表达式。我已经尝试过,
/*.*
*.*
/([^/.]*)
如果我使用“不匹配”设置,前两个将与 /ANN 一起使用,但它们也可以在默认地址 www.website.com/ 上工作。第三个,源,根据 IIS,与 /ANN 不匹配表情检查器。
我很感激任何正则表达式向导可以提供的任何建议。非常感谢。
I have a dynamic list of "referrers", example ANN, BOB, ..., ZED. I want people who go to my url www.website.com/ANN, www.website.com/BOB, www.website.com/ZED to be directed to a special dynamically generated referrer page.
What I want to do is set up a URLRewriter rule on my IIS7 that will direct any page without a file extension to a /reroute.aspx which will handle generating the dynamic page. What I'm having a problem with is the regular or wildcard expression. I've tried
/*.*
*.*
/([^/.]*)
The first two will work with /ANN if I use the "Does not match" setting, but then they also work on www.website.com/ which is the default address. The third one, Source, doesn't match /ANN according to the IIS expression checker.
I'd appreciate any advice any regex wizards could provide. Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑:我只是想到了一些事情......也许领先的
/
不应该在那里。您可以尝试这样做:我也在想,要传递查询字符串,您可以这样做:
...并在替换字符串中使用
{C:2}
来复制查询字符串。$
很重要:话又说回来,也许不是……这实际上只是一个猜测。
Edit: I just thought of something... maybe the leading
/
shouldn't be there. You could try this:I'm also thinking, to pass querystrings through, you could possibly do this:
...and use
{C:2}
in the replacement string to copy over the querystring.The
$
is important:Then again, maybe not... it's really just a guess.
最后我放弃了尝试使用这样一个简单的链接,并使用 www.website.com/Refer/ANN
我使用的查询字符串是
refer/([A-Za-z0-9]+)$
奥利维尔是对的,$ 很重要:)
In the end I just gave up trying to use such a simple link, and am using www.website.com/Refer/ANN
The Query string I am using is
refer/([A-Za-z0-9]+)$
And Olivier was right, the $ is important :)