如何重写 URL,如:www.foo.com/tags/tag1+tag2 --> www.foo.com/Pages/Articles/ArticleListing.aspx?tags=tag1+tag2
如何添加单个重写规则 -
www.foo.com/tags/tag1 --> www.foo.com/Pages/Articles/ArticleListing.aspx?tags=tag1
www.foo.com/tags/tag1+tag2 --> www.foo.com/Pages/Articles/ArticleListing.aspx?tags=tag1+tag2
www.foo.com/tags/tag1+tag2+tag3 --> www.foo.com/Pages/Articles/ArticleListing.aspx?tags=tag1+tag2+tag3
How to add single rewrite rule for-
www.foo.com/tags/tag1 --> www.foo.com/Pages/Articles/ArticleListing.aspx?tags=tag1
www.foo.com/tags/tag1+tag2 --> www.foo.com/Pages/Articles/ArticleListing.aspx?tags=tag1+tag2
www.foo.com/tags/tag1+tag2+tag3 --> www.foo.com/Pages/Articles/ArticleListing.aspx?tags=tag1+tag2+tag3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
类似下面的内容应该适用于 Apache + mod_rewrite:
NC = 不区分大小写,L = 如果匹配则最后一条规则
此模式将匹配“tags/”之后的任何文本,并将其用作查询参数“tags”。为了实现这一点,您使用括号作为一个“组”,然后您可以稍后使用 $1(第一组)引用它,任何较晚优先的括号将被视为 $2、$3 等。因此,您可以在一个中包含多个匹配项图案。
您可以在这里找到文档:
http://httpd.apache.org/docs /2.0/mod/mod_rewrite.html
Something like the following should work for Apache + mod_rewrite:
NC = no case sensitivity, L = last rule if this matches
This pattern will match any text after "tags/" and use it as the query parameter "tags". To achieve this, you use the parentheses as a "group" which you can then refer to later using $1 (the first group), any later-precedence parentheses would be considered $2, $3, etc. So you can have multiple matches in one pattern.
You can find the documentation here:
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html