大网数据广告活动
网站运营与故障问答

How to migrate from the old domain to the new domain?

· 52CE 我爱测

I just got finished with moving my site from one domain name to another. All old links on social media and search engines are broken. If I click on a link from reddit or Facebook it still points to olddomain.com . Even though if …

问题原文

原帖链接 · jjf3 · CC BY-SA 4.0

I just got finished with moving my site from one domain name to another. All old links on social media and search engines are broken. If I click on a link from reddit or Facebook it still points to olddomain.com. Even though if I type olddomain.com into a browser, newdomain.com does pop up. Is there anyway I can resolve this issue? All I did was export the old site data, switched to the new site, and imported the new site back. What am I missing now?

Google is coming with weird results when I search for this topic. I am using godaddy and wordpress with over 500 posts if it matters and I set up 301 redirect on the main olddomain.com to the newdomain.com so that works.

As requested by the community my .htaccess file is below:

#I have 500 of these for each link: 
redirect 301 people-of-earth-unrenewed-at-tbs/ http://channelactivist.com/people-of-earth-unrenewed-at-tbs/

#Then I have this at the end:
# Redirect the site 
RewriteEngine On 
# Take care of www.johnjfalco.com 
RewriteCond %{HTTP_HOST} ^www.johnjfalco.com$ [NC] 
RewriteRule ^(.*)$ http://channelactivist.com/$1 [L,R=301]

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress

已采纳解答

原帖链接 · Alexis Wilke · CC BY-SA 4.0

All the existing links won't automatically change to the new domain. They never will, except on some websites that take the time or have that automated.

But as long as you keep olddomain.com with the 301 redirect, clicking on those old links should bring the people to the new site just fine.

However, it is not unlikely that Facebook and Twitter will lose the image/preview, whatever you'd want to call that one. In Facebook, it's possible to edit the post and replace the default image from the website with an image that you directly upload on Facebook. It takes more time to do that, but from what I understand, those pictures will stick around.

As Pasakgroup mentioned, telling Google through the Google Console will help with SEO on Google by transferring the old juice to the new domain as you make it official there.


Update from links:

I tested with wget which allows me to see the reply header:

$ wget -S http://johnjfalco.com/people-of-earth-unrenewed-at-tbs/
--2018-06-28 18:39:15--  http://johnjfalco.com/people-of-earth-unrenewed-at-tbs/
Resolving johnjfalco.com (johnjfalco.com)... 184.168.131.241
Connecting to johnjfalco.com (johnjfalco.com)|184.168.131.241|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 404 Not Found
  Server: nginx/1.12.2
  Date: Fri, 29 Jun 2018 01:39:15 GMT
  Content-Type: text/html; charset=utf-8
  Transfer-Encoding: chunked
  Connection: close
2018-06-28 18:39:15 ERROR 404: Not Found.

As we can see, we get a 404, not a 301. So I'm not too sure how you think you implemented the 301, but it doesn't see to work right for all pages.

I also tested the home page and that one has a 301 as expected:

$ wget -S http://johnjfalco.com/
--2018-06-28 18:41:17--  http://johnjfalco.com/
Resolving johnjfalco.com (johnjfalco.com)... 184.168.131.241
Connecting to johnjfalco.com (johnjfalco.com)|184.168.131.241|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 301 Moved Permanently
  Server: nginx/1.12.2
  Date: Fri, 29 Jun 2018 01:41:17 GMT
  Content-Type: text/html; charset=utf-8
  Transfer-Encoding: chunked
  Connection: close
  Location: http://channelactivist.com
Location: http://channelactivist.com [following]
--2018-06-28 18:41:17--  http://channelactivist.com/

As we can see here, we get an HTTP/1.1 code of 301 and a Location: with the new domain name. So the home page is working, but not the other pages.

So now the next question is: how did you implement the redirects? If you asked GoDaddy to do it, it's not going to work right. You should keep the website on your account and add an .htaccess file with the code as shown in the other answer.

RewriteEngine on
RewriteRule ^/(.*)$ http://channelactivist.com/$1 [R=301,L]

What this does is take any path from the existing request (^/(.*)$) and stick it at the end of the new URL (the $1). That way a URL such as:

http://old.example.com/some/path/and/filename.html

can become:

http://new.example.com/some/path/and/filename.html

However, showing us your existing .htaccess code may help us more resolving your redirect problem. (please put in your question)


Update about the .htaccess file.

Here you have a condition, which makes sense, only you very specifically test for www...

RewriteCond %{HTTP_HOST} ^www.johnjfalco.com$ [NC]

I would not test the www part and you probably don't really need the ^ and $ because you probably won't get hits with names that don't match a domain you own (not much and very unlikely would it match your old domain.)

I would change that condition to this:

RewriteCond %{HTTP_HOST} johnjfalco.com [NC]

This being said, if GoDaddy is in the middle (which would explain why we get a GoDaddy 404 page) then just changing the .htaccess file won't be sufficient.


I tested the latest and see a 302 instead of a 301.

Not only that, the redirect does not include a domain name. That's not correct. You must include a protocol and domain name in the Location: ... field.

Just in case, I tested with my browser which has Firebug and clicked the Network tab. This shows you the Location header field.

So... the .htaccess you shown us is not what is generating the redirect at the moment. It could still be GoDaddy being in control. You should cut them out completely. Your old domain is good until September, so that's not the problem.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2018-06-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。