【问题标题】:Redirect subdomain to new domain with htaccess使用 htaccess 将子域重定向到新域
【发布时间】:2013-10-08 20:29:27
【问题描述】:

我正在尝试重定向页面,例如:

c.domain1.se/folder1/main.html

www.domain2.se/folder1/main.html

我的 htaccess 看起来像这样:

RewriteCond %{HTTP_HOST} c\.domain1\.se$ [NC] 
RewriteRule ^ domain2.se%{REQUEST_URI} [QSA,R=301,L,NE]

我收到以下消息:

Forbidden
You don't have permission to access /set on this server.

Webhost 声称没有其他 htaccess 文件干扰 c.domain1.se 上的文件。

对可能是什么问题有任何想法吗?

【问题讨论】:

    标签: .htaccess redirect subdomain


    【解决方案1】:

    您应该在规则的目标中包含方案并为条件匹配添加边界(通过^):

    RewriteCond %{HTTP_HOST} ^c\.domain1\.se$ [NC] 
    RewriteRule ^ http://domain2.se%{REQUEST_URI} [QSA,R=301,L,NE]
    

    【讨论】:

      【解决方案2】:

      试试这个代码:

      RewriteCond %{HTTP_HOST} ^c\.domain1\.se$ [NC] 
      RewriteRule ^ http://domain2.se%{REQUEST_URI} [R=301,L,NE]
      

      【讨论】:

        猜你喜欢
        • 2014-08-19
        • 2023-03-09
        • 1970-01-01
        • 2019-12-20
        • 2013-02-20
        • 1970-01-01
        • 2011-08-27
        • 1970-01-01
        相关资源
        最近更新 更多