![多个扩展重定向至一个](https://linux22.com/image/606382/%E5%A4%9A%E4%B8%AA%E6%89%A9%E5%B1%95%E9%87%8D%E5%AE%9A%E5%90%91%E8%87%B3%E4%B8%80%E4%B8%AA.png)
我购买了 1 个具有不同扩展名的域名(.fr、.com、.org、.net),我听说如果不将它们全部重定向到一个域名,对 SEO 非常不利。
我的问题很简单。我该怎么办?我有一个装有 Apache2 的 VPS。
谢谢!
答案1
让所有域指向一个 Web 服务器并像这样配置它(给出 apache 的示例):
# Necessary for named vhosts
NameVirtualHost *:80
<VirtualHost *:80>
# Accept all domains for this vhost
ServerName foo.com
ServerAlias foo.fr
ServerAlias foo.org
ServerAlias foo.net
RewriteEngine on
# Match requests that don't have the main domain only...
RewriteCond %{HTTP_HOST} (?:www\.)?foo\.(?:fr|org|net)
# ... rewrite them to use the main domain
RewriteRule ^/(.*)$ http://foo.com/$1 [R,L]
</VirtualHost>