RewriteRule 将字符串添加到 URL 末尾
这对我不起作用:
RewriteRule ^tags/[^?/] Templates/showpage.asp?DBID=1&LNGID=2&TMID=133&FID=898&tag=%1 [QSA]
当我转到页面 www.mydomain.com/tags/tag1
时,它会将其重写为 www.mydomain.com/Templates/showpage.asp?DBID= 1&LNGID=2&TMID=133&FID=898&tag=
。
如何将“tag1”添加到 URL?
This is not working for me:
RewriteRule ^tags/[^?/] Templates/showpage.asp?DBID=1&LNGID=2&TMID=133&FID=898&tag=%1 [QSA]
When I go to page www.mydomain.com/tags/tag1
, it rewrites it to www.mydomain.com/Templates/showpage.asp?DBID=1&LNGID=2&TMID=133&FID=898&tag=
.
How do I add "tag1" to the URL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有 ISAPI 经验,但我可能会尝试这样做:
本质上,您缺少的是用于捕获要用于代替
$1
的匹配标记的括号,我放置了条件斜杠 (< code>/?) 在括号外,假设标签不应包含斜杠,但带或不带尾部斜杠的 URL 都是可接受的。
更新
如果您需要更自由地接受哪些字符作为标签,您可以使用类似
^tags/([^/?]+)/?$
的内容来允许所有字符(斜杠除外)和问号)正如 Pavel 的建议。No experience with ISAPI, but I would probably try this:
Essentially, what you're missing is the brackets to capture the matching tag that is to be used in place of
$1
I placed the conditional slash (
/?
) outside the bracket with the assumption that tags shouldn't contain the slash but URLs with or without the trailing slash are acceptable.Update
If you need to be more liberal with what characters you accept as tags, you can use something like
^tags/([^/?]+)/?$
to allow all characters (apart from slash and question mark) as suggested by Pavel.试试这个:
Try this: