开发者

RewriteRule to add string to end of 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?


No experience with ISAPI, but I would probably try this:

RewriteRule ^tags/(\w+)/?$ Templates/showpage.asp?DBID=1&LNGID=2&TMID=133&FID=898&tag=$1 [QSA]

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:

RewriteRule ^tags/([^?/]+) Templates/showpage.asp?DBID=1&LNGID=2&TMID=133&FID=898&tag=%1 [QSA]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜