2014-10-20 63 views
-1

我不得不重新映射几个ID对URL字符串(301重定向),我有mod_rewrite的做到这一点:简单的Apache mod_rewrite的重映射

/page.php?id=15 to /pagexy 
/page.php?id=10 to /pageyz 

规则:

RewriteRule ^page.php?id=15$ /pagexy [L,R=301] 

不工作。我究竟做错了什么?

回答

0

您需要单独检查查询字符串。下面应该工作:

RewriteEngine On 

RewriteCond %{QUERY_STRING} id=15\b [NC] 
RewriteRule ^/page.php$ /pagexy? [L,R=301] 

RewriteCond %{QUERY_STRING} id=10\b [NC] 
RewriteRule ^/page.php$ /pageyz? [L,R=301] 

鉴于你绑ID来页,可能还要看看使用RewriteMap