重定向保留查询字符串

时间:2014-09-04 03:16:22

标签: .htaccess redirect

如何重定向保留查询字符串的用户?

示例1:

www.mydomain.com/pages/welcome.html?abc=123

www.mydomain.com/pages/welcomeNew.html?abc=123

示例2:

www.mydomain.com/pages/welcome.html?xyz=321

www.mydomain.com/pages/welcomeNew.html?xyz=321

我试过这个并不起作用?

 RewriteEngine On
    RewriteRule ^pages/welcome.html?([a-z0-9]*)$ www.mydomain.com/pages/welcomeNew.html?$1 [R=301,L,QSA]

1 个答案:

答案 0 :(得分:0)

根本不需要?。查询字符串将自动保留:

RewriteEngine On
RewriteRule ^pages/welcome.html$ /pages/welcomeNew.html [R=301,L,QSA]