如何从一个域重定向到另一个域? [英] How to redirect from one domain to another?
本文介绍了如何从一个域重定向到另一个域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个域
abc.ca已经在运行& google抓取了该网址。
I have one domain abc.ca is already running & google crawled that url.
现在我要买
abc.com
Now i'm going for abc.com
我可以使用htacees管理abc.ca-> abc.com
so how can i manage all URL's of abc.ca -> abc.com
的所有URL吗?该网站内置于PHP Joomla中。
using htacees. Site is built in PHP Joomla.
abc.ca/def.html-> abc.com/def.html
abc.ca/def.html -> abc.com/def.html
有数千页。我无法在htaccess中编写单独的301重定向。
there are thousands of pages. I can't write individual 301 redirection in htaccess.
我们可以在PHP中做到这一点
We can do this in PHP
$uri = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$newUrl = str_replace(".ca", ".com", $uri);
header("Location: " . $newUrl);
最好在PHP网站或htaccess网站上做吗?
It's better to do on PHP site or htaccess site?
推荐答案
您可以尝试以下操作:
RewriteCond %{HTTP_HOST} !^www\.abc.\.com
RewriteRule ^(.*)$ http://www.abc.com/$1 [R=permanent,L]
这篇关于如何从一个域重定向到另一个域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文