使用 301 和 .htaccess 永久重定向

Permanent redirect using 301 and .htaccess

我在旧域 (http://domain1.com) and I move it to a new one (http://domain2.com) 中有一个站点,因为该站点在 domain1.com 上的 SEO 位置很好,我不想松动,所以我需要保留它,我认为在通过 .htaccess 文件的 301 重定向中。这是我要添加到 .htacess 文件的行:

Redirect 301 /http://domain2.com/

但是,

  • Is this the right way?
  • Is the line above good?
  • Since I haven't the hosting (files and more) under domain1.com should the .htaccess file be on domain2.com hosting?

能解开我对这个话题的疑惑吗?

是的,这是很好的解决方案。 301 是永久重定向,在标准 HTTP 代码中声明。如您所写,您可以使用 .htaccess 文件来执行此操作,或者配置 DNS 服务器以将所有查询自动重定向到该域(请参阅 http://help.dnsmadeeasy.com/spry_menu/http-redirection-record/)。我认为第二种解决方案更好,因为您不再需要为托管付费。