2015-02-07 28 views
0

如何將流量重定向從www.old.comwww.new.com的.htaccess所有流量重定向到域,但很少手寫例外

  • www.old.com/hellowww.new.com/byebye
  • www.old.com/test?start=5www.new.com/page/site

我有這樣的開始與:

RewriteEngine On 
RewriteBase/

# root 
RewriteCond %{HTTP_HOST} ^www\.(([^\.]+))\.pl [NC] 
RewriteRule ^(.*)$ http://%1.pl%{REQUEST_URI} [R=301,L] 

# Redirect 
Redirect permanent old.com/hello new.com/byebye 

回答

0

您可以使用此.htaccess:

RewriteEngine On 
RewriteBase/

# redirect 
RewriteCond %{HTTP_HOST} ^www\.old\.com$ [NC] 
RewriteRule ^hello$ http://www.new.com/byebye [NC,R=301,L] 
RewriteCond %{HTTP_HOST} ^www\.old\.com$ [NC] 
RewriteCond %{QUERY_STRING} ^start=5$ [NC] 
RewriteRule ^test$ http://www.new.com/page/site? [NC,R=301,L] 

# root 
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.pl [NC] 
RewriteRule^http://%1.pl%{REQUEST_URI} [R=301,L] 
相關問題