【问题标题】:Redirect subdomain to domain with .htaccess in domain directory使用域目录中的 .htaccess 将子域重定向到域
【发布时间】:2014-05-21 01:00:03
【问题描述】:

我的网页以前是 blog.example.com,但现在是 example.com。我不得不删除 /blog 目录(网站托管 blog.example.com),因为我在 URL example.com/blog 上有一个 Wordpress 页面,这搞砸了。

我试过了:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^blog\.example\.com
RewriteRule ^(.*)$ http://www\.example\.com/$1 [L]

还有:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?blog\.example\.com$ [NC]
RewriteRule ^ http://www.example.com/%{REQUEST_URI} [NE,R=301,L]

还有:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^blog\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

但这些都不会对子域产生任何影响。 我该怎么做才能将 blog.website.com/URLS 重定向到 website.com/URLS?(不创建 example.com/blog,因为它会弄乱 Wordpress 的网页网站.com/blog)

【问题讨论】:

    标签: wordpress apache .htaccess redirect


    【解决方案1】:

    我想通了!我不得不:

    1. 从 bluehost 中删除应该重定向的重定向 子域到主域
    2. 在 public_html/blog-redirect 目录下创建子域 blog.example.com
    3. 将此重定向代码添加到 /blog-redirect 下的 .htacces 文件中:

      RewriteEngine On
      RedirectMatch 301 ^/(.*)$ http://example.com/$1
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-28
      • 1970-01-01
      • 2012-09-07
      • 1970-01-01
      • 1970-01-01
      • 2014-08-19
      • 2023-03-09
      • 1970-01-01
      相关资源
      最近更新 更多