Php .htaccess根据get参数将url重定向到不同的位置

Php .htaccess根据get参数将url重定向到不同的位置,php,.htaccess,redirect,Php,.htaccess,Redirect,我想根据get参数将url重定向到不同的位置,似乎只有第一个规则可以形成这种形式,而其余规则则被忽略 http://example.com/def?attachment_id=365 http://example.com/abcdef http://example.com/def?attachment_id=360 http://example.com/hujkl 下面是我使用的代码: RewriteCond %{QUERY_STRING} ^attachment_id=365$ R

我想根据get参数将url重定向到不同的位置,似乎只有第一个规则可以形成这种形式,而其余规则则被忽略

http://example.com/def?attachment_id=365    http://example.com/abcdef
http://example.com/def?attachment_id=360   http://example.com/hujkl
下面是我使用的代码:

RewriteCond %{QUERY_STRING} ^attachment_id=365$
RewriteRule ^def/$ http://example.com/abcdef [L,R=301]

RewriteCond %{QUERY_STRING} ^attachment_id=360$
RewriteRule ^def/$ http://example.com/hujkl [L,R=301]
RewriteCond %{QUERY_STRING} attachment_id=365
RewriteRule ^$ http://example.com/? [L,R=301]

RewriteCond %{QUERY_STRING} page_id=8
RewriteRule ^$ http://example.com/def? [L,R=301]