【问题标题】:Redirect subdomain to another subdomain将子域重定向到另一个子域
【发布时间】:2012-05-08 12:02:30
【问题描述】:

我想知道如何将子域重定向到另一个子域以及不同的域名

例如

我想重定向子域

forum.example.com

forum.example.net

谢谢

【问题讨论】:

    标签: apache .htaccess redirect subdomain


    【解决方案1】:

    此代码应该适合您。您需要将重定向添加到您的 .htaccess 文件中。

    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^example.com [nc]
    rewriterule ^(.*)$ http://www.example.net/$1 [r=301,nc
    

    另一个不错但懒惰的方法是使用以下链接,为您生成代码htaccesss generator

    【讨论】:

      【解决方案2】:

      通过httpd.conf启用mod_rewrite和.htaccess,然后把这段代码放到你.htaccessDOCUMENT_ROOT目录下:

      Options +FollowSymLinks -MultiViews
      # Turn mod_rewrite on
      RewriteEngine On
      RewriteBase /
      
      RewriteCond %{HTTP_HOST} ^forum\.example\.com$ [NC]
      RewriteRule ^ http://forum.example.net%{REQUEST_URI} [R,L]
      

      【讨论】:

        猜你喜欢
        • 2023-02-14
        • 1970-01-01
        • 1970-01-01
        • 2019-01-12
        • 2013-08-04
        • 2012-03-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多