使用获取变量重定向旧站点

时间:2017-10-23 11:38:54

标签: .htaccess

在htaccess文件中,我需要将所有旧网站网址重定向到新网址。

我的实际重定向只是get变量中的页面url(源代码) 我需要添加第二个变量(酒店),以便在它存在时重新使用它。

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://newsite.com/page/?source=$1 [R=permanent,L]

1 个答案:

答案 0 :(得分:0)

您可以使用:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://newsite.com/page/?source=$1 [R=permanent,QSA,L]
  

QSA | qsappend :当替换URI包含查询字符串时,RewriteRule的默认行为是放弃现有查询   string,并将其替换为新生成的字符串。使用[QSA]   flag会导致查询字符串合并。
  http://httpd.apache.org/docs/current/en/rewrite/flags.html#flag_qsa

相关问题