【问题标题】:How can I redirect all pages of a subdomain to the add-on pages?如何将子域的所有页面重定向到附加页面?
【发布时间】:2012-04-25 18:40:02
【问题描述】:

基本上,谷歌列出了我的附加域的所有子域页面。

谷歌列表 http:// 万维网。 mymainwebsite.com(这很好)

还有

http://www.子域。 mymainwebsite.com(不好)

所以........在htaccess中我添加了这个:

RewriteCond %{HTTP_HOST} ^subdomain.mymainwebsite.com$ [OR]

RewriteCond %{HTTP_HOST} ^www.subdomain.mymainwebsite.com$

重写规则 ^/?$ "http\://www.mymainwebsite.com/" [R=301,L]

这适用于主子域,但我可以“仍然访问”所有子域页面,例如我仍然可以访问: http:// 万维网。 subdomain.mymainwebsite.com/about

Google 已经列出了“数百个”上述子域“页面”

所以我的问题是......我可以在我的 htaccess 中添加任何“代码”,它会重定向“所有”不幸在谷歌中列出的子域“页面”吗?

我想要http://www.subdomain.mymainwebsite.com/about(常见问题/历史/联系人/链接,还有数百页)

前往

http://www.mymainwebsite.com/about(常见问题/历史/联系人/链接,以及数百页)

谢谢大家!

【问题讨论】:

    标签: .htaccess redirect dns rewrite add-on


    【解决方案1】:

    您需要告诉重写引擎将 URL 的其余部分添加到重写中。

    它应该看起来像这样:

    RewriteRule ^/(.*)$ "http\://www.mymainwebsite.com/$1" [R=301,L]

    这会将您子域上的所有路径重定向到您的主域。

    $1 是对 (.*) 的反向引用,它匹配斜杠后的所有字符。使用 $1 会在重定向中包含这些字符。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-08
      • 2016-04-20
      • 1970-01-01
      • 2013-02-28
      • 2011-09-13
      • 2013-12-05
      相关资源
      最近更新 更多