如何 301 重定向 htaccess with & sign



From/?act=view&id=NUMBER to URL

例子:

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

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

我的代码

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

你不能使用

Redirect 指令操作查询字符串,你需要使用 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]

最新更新