douben8492 2014-12-16 14:17
浏览 24
已采纳

从子域到root:最好的方法? [关闭]

I am not asking for a technical solution, just a plain "what approach would you recommend" vis-a-vis SEO, crawlability and user experience.

Imagine I am selling pastry on my website (let's call it pastry.com). I would like people specifically searching for cakes on google to go to my subdomain "cake.pastry.com" (listed as such on Google).

But, since I don't want to maintain multiple subdomains, "cake.pastry.com" would actually redirect to "pastry.com#cake", so that this approach could also be used for cupcakes and muffins! "cupcake.pastry.com" redirects to "pastry.com#cupcake", etc.

What would be the best way to do this? Is it possible to keep "cake.pastry.com" in the address bar while users are actually redirected "pastry.com#cake"? Would this pose a UX problem? Also, will this subdomain bring any value? I.e., will people searching for cakes on google actually find the "cake.pastry.com" subdomain higher than the root domain (because of keyword density, specificity of content...)? Would I need a 301 or 302 redirect? Via PHP or .htaccess?

So please, any opinion is welcome! Thank you!

  • 写回答

1条回答 默认 最新

  • dousongqiang2585 2014-12-16 14:44
    关注

    I cannot fully answer the SEO parts of this question. But as far as I know, it is no good idea to list a page with different domains at Google. Beside this, subdomains are not made for this purpose. At least I like addresses like http://pastry.com/cake much more than your examples.

    The technical answer:

    1. You need an wildcard DNS record to map all subdomains to pastry.com
    2. You can rewrite with mod_rewrite

    I've not tested this, but this is more an example to show how this might work:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.pastry\.com$
    RewriteCond %{HTTP_HOST} !^pastry\.com$
    RewriteCond %{HTTP_HOST} ([^\.]+)\.pastry\.com  [NC]
    RewriteRule ^(.*)$ http://pastry.com/#%1 [NE,R=301,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路