如何301重定向htaccess与&标志

时间:2016-04-22 13:55:59

标签: .htaccess

从/?act = view& id = NUM​​BER到URL

的示例:

/?act = view& id = 1 to http://google.com

/?act = view& id = 2 to http://facebook.com/blabla

我的代码



Redirect 301 /?act=view&id=157 http://google.com




1 个答案:

答案 0 :(得分:0)

您无法使用重定向指令操纵查询字符串,您需要使用mod-rewrite,

尝试:

RewriteEngine on

#1)Redirect "?act=view&id=1" to "http://google.com/"#
RewriteCond %{THE_REQUEST} \?act=view&id=1 [NC]
RewriteRule ^ http://google.com/? [NC,L,R]
#2)Redirect "?act=view&id=2" to "http://facebook.com/"#
RewriteCond %{THE_REQUEST} \?act=view&id=2 [NC]
RewriteRule ^ http://facebook.com/? [NC,L,R]