URLRewriter.net 具有多个由 / 分隔的查询字符串
我在该网站上浏览了一下,但没有找到任何关于如何按照我想要的方式进行操作的回复。
我想要的是这样的 URL:
www.example.com/Projects/"querystring1 - 仅文本"/"querystring2 - 仅 4 位数字"/
显示具有以下 URL 的页面:
www.example.com/Projects.aspx? Region=querystring1&Zip=querystring2
我一直在尝试的是以下内容:
<rewrite url="~/Leje-og-udlejning-arbejdskraft/(.+)/(.+)" to="~/Workers.aspx?Region=$1&zip=$2"/>
但它只是将它们作为一个查询字符串并将它们放入区域查询字符串中。
I have been looking around the site a bit, but I didn't find any replies on how to do it the way I want.
What I want is an URL like this:
www.example.com/Projects/"querystring1 - text only"/"querystring2 - 4 digits only"/
to show the page with this URL:
www.example.com/Projects.aspx?Region=querystring1&Zip=querystring2
What I have been trying is the following:
<rewrite url="~/Leje-og-udlejning-arbejdskraft/(.+)/(.+)" to="~/Workers.aspx?Region=$1&zip=$2"/>
But it just takes both of them as one querysting and put them in the Region-querystring.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我需要查看其余的重写规则才能确定,但是如果您有多次重写(即处理用户仅指定两个查询字符串之一的情况),则忽略添加
processing="stop"< /code> 末尾将导致一个规则覆盖另一个规则。
例如,我在 web.config 文件中使用以下设置:
这将首先检查是否存在 2 个查询变量。如果是,它会适当地重写它们并停止处理其他规则。这是大事。最后没有
processing="stop"
,我最终将两者作为ref
查询字符串传递。这可能就是您遇到的冲突。I'd need to see the rest of your rewrite rules to be sure, but if you have multiple rewrites (i.e. to handle situations where users only specify one of the two query strings) neglecting to add
processing="stop"
at the end will cause one rule to override the other.For example, I use the following setup in my web.config file:
This will first check to see if 2 query variables are present. If they are, it rewrites them appropriately and stops processing other rules. This is the biggie. Without
processing="stop"
at the end, I end up passing both as theref
query string. This might be the conflict you're running in to.