【问题标题】:301 redirection of all pages except the homepage301重定向除首页外的所有页面
【发布时间】:2012-01-24 21:32:39
【问题描述】:

我想要实现的是域的所有页面/资源的 301 重定向除了站点的根目录,然后每个页面都应该从 www.example.com/example 移动。 com 到 old.example.com。

我不是 htaccess 大师,但这是我想出的解决方案...

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

但是好像不行

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    您在 RewriteCond 中缺少 TestString

    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
    #if not root
    RewriteCond %{REQUEST_URI} !^/?$ [NC]
    #redirect
    RewriteRule ^(.*)$ http://old.example.com/$1 [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 2020-03-11
      • 2012-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-14
      • 2016-11-30
      • 1970-01-01
      相关资源
      最近更新 更多