更新时间:2023-02-24 10:36:59
您可以尝试使用常规的前pression和分组,如果你的服务器支持。如果我没有记错,你必须重写只有一个参数,我想你可以(如果你使用的是Apache与mod_rewrite的)尝试类似:
You can try to use regular expression and grouping, if your server supports that. If I am not mistaken you have to rewrite only one parameter, I guess you could try something like (if you are using apache with mod_rewrite):
RewriteCond %{QUERY_STRING} ^.*(\btag\b=(\w+|&\w+;)+)
RewriteRule ^(.+) /$1?%1 [L]
编辑:我改进了常规EX pression一点点地匹配标签,无论它的位置在查询字符串和preserve特殊字符序列,如&放大器;放大器;
另外也应避免与类似的参数(即:它不会被称为alttag参数相匹配)匹配
I improved the regular expression a little bit to match "tag" regardless of its position in the query string and to preserve special characters sequences such as &
In addition it should avoid matches with similar parameters (i.e.: it wouldn't match a parameter called "alttag").
编辑#2:的替代(尤其是如果你要筛选一些参数)是使用外部程序做了改写。本页面:http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritemap (特别是部分外部重写程序)中包含的有用信息。
Edit #2: An alternative (especially if you have to filter several parameters) is to use an external program to do the rewrite. This page: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritemap (in particular the section "External rewriting program") contains useful information.