Multiple domains to single website

时光总嘲笑我的痴心妄想 提交于 2019-12-23 12:15:42

问题


I have multiple domains pointing at the same website. (FFFF.com, FFFF.ca, FFFF.org, etc)

What's the best way to achieve a rewrite to FFFF.com all incoming traffic?

URL rewrites or 301s? Looking for best practice. These two would be dealt with within htaccess right?

Thanks,


回答1:


You would want to do a 301 in this instance. In general, if you're trying to figure out which method is best practice, it's usually the choice that makes it clear to the client what is going on. Transparently re-writing makes it look like three domains have the same content. A 301 politely informs the client that the content resides somewhere else.




回答2:


Use this code in your .htaccess:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^(www\.)?FFFF\.com$ [NC]
RewriteRule ^ http://FFFF.com/%{REQUEST_URI} [R=301,L]

This basically 301 redirects all the URIs to FFFF.com if domain name in request is NOT FFFF.com.



来源:https://stackoverflow.com/questions/9519873/multiple-domains-to-single-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!