我正在尝试将网站a重定向到具有相同网址结构的网站b。我的htaccess是
Redirect 301 / http://www.siteb.com/
RewriteRule ^(.*)/(.*)/(.*)$ index.php?video=$1&id=$2&words=$3
RewriteRule ^videos/(.*)$ index.php?videos=$1
但是,在重定向的网站上,它会添加其他变量。例如;
siteA.com/y/T5INF08ZEdA/Miranda-Kerr-In-Hot-Water-with-Orlando-Bloom
siteB.com/y/T5INF08ZEdA/Miranda-Kerr-In-Hot-Water-with-Orlando-Bloom?video=y&id=T5INF08ZEdA&words=Miranda-Kerr-In-Hot-Water-with-Orlando -Bloom
301使用相同网址结构重定向的正确方法是什么?
答案 0 :(得分:1)
这是因为代码中存在两个主要问题:
L
标志,导致在同一网址上触发多个规则。我建议你只坚持使用mod_rewrite并保留你的.htaccess:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)sitea\.com$ [NC]
RewriteRule ^ http://www.siteb.com%{REQUEST_URI} [L,R=301]
RewriteRule ^videos/(.*)$ index.php?videos=$1 [L,QSA,NC]
RewriteRule ^([^/]+)/([^/]+)/(.*?)/?$ index.php?video=$1&id=$2&words=$3 [L,QSA]