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

How to move SEO from a separately hosted subdomain into main domain?

· 52CE 我爱测

I have a main domain: example.com and a subdomain: blog.example.com that I really want combined for SEO benefit, but my blog.example.com uses PHP which is not supported by my website provider on example.com . I thought perhaps I …

问题原文

原帖链接 · WilliamKF · CC BY-SA 3.0

I have a main domain: example.com and a subdomain: blog.example.com that I really want combined for SEO benefit, but my blog.example.com uses PHP which is not supported by my website provider on example.com.

I thought perhaps I could move my blog.example.com into blog.example.com/info and create a robots.txt file for blog.example.com to tell search engines to not index the subdomain and then create example.com/blog as a masking redirect to blog.example.com/info. Will this cause the blog to only be indexed once by search engines and make it appear as if the blog (PHP) site is hosted under the main domain?

If not, is there another approach I could take here instead? The goal is to have the blog SEO attributed to the main domain whose hosting does not permit PHP.

已采纳解答

原帖链接 · MrWhite · CC BY-SA 3.0

...create example.com/blog as a masking redirect to ...

Yes, in theory, you can do exactly that. Note that by "masking redirect" we are not talking about "framed forwarding" or similar (which won't help at all). The "redirect" is completely "masked" from the user. The address in the browser's address bar shows example.com/blog but the server actually retrieves the content from blog.example.com/ (an additional / proxied request).

On Apache you can use mod_proxy (and optionally mod_rewrite) to proxy the request from example.com/blog to blog.example.com (a reverse proxy). However, if your current host is too restrictive (after all, it doesn't support PHP?) then this might not be possible. This is likely to require some additional config on your blog, since the base URL is now example.com/blog and not blog.example.com/.

move my blog.example.com into blog.example.com/info

Not sure why you would want to do this seemingly "additional" step? (Why /info?) You don't need to move your blog anywhere. example.com/blog would go straight to blog.example.com.

create a robots.txt file for blog.example.com to tell search engines to not index the subdomain.

You definitely must not do this! If you suddenly block the search engines from crawling the old URLs then bang goes your SEO! You will essentially be starting from scratch. Moving from blog.example.com to example.com/blog is a URL change/migration. Like any URL change you would need to setup 301 (permanent) redirects from the old to new URLs - this allows search engines to discover the new URLs where the old URLs have already been indexed. And like any URL change you might experience a dip in ranking initially. There is always a risk.

So, the basic steps involved would be:

  1. Proxy all the requests from example.com/blog/ to blog.example.com/.
  2. Change all your internal links to your new blog URL.
  3. Setup external (301) redirects from the old to new URLs. ie. blog.example.com/ to example.com/blog/.

However, I'm not convinced that "changing" the existing URL structure is going to be "worth it". As mentioned above, there is always a risk in changing the URL structure and having the blog under the same host (as opposed to a separate subdomain) may not see the SEO advantage you are seeking.

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

资料来源与适用范围

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

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

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