1

我在 htaccess 中有以下内容,它工作正常

RewriteCond %{REQUEST_URI}  ^/artist\.php$
RewriteCond %{QUERY_STRING} ^bandid=([0-9]*)$ [NC]
RewriteRule ^(.*) /band.php?BandId=%1 [L]

但是一些旧的引用发送其他查询字符串参数:

bandid=1326&order=ASC&orderby=Tdate

阿帕奇给他们的404

我怎么能告诉mod_rewrite在bandid之后忽略任何其他参数

4

1 回答 1

3

用这个替换你的代码:

RewriteCond %{QUERY_STRING} (?:^|&)bandid=([0-9]*)(?:&|$) [NC]
RewriteRule ^artist\.php$ /band.php?BandId=%1 [L,NC]

无论是否存在其他查询参数,Regex (^|&)bandid=([0-9]*)(&|$)都会确保匹配。bandid=1326

于 2013-09-14T11:42:35.223 回答