【问题标题】:Redirect entire site except one directory to a new site - apache .htaccess将除一个目录之外的整个站点重定向到新站点 - apache .htaccess
【发布时间】:2011-03-27 19:33:30
【问题描述】:

我正在尝试将当前站点移至新域,但 ONE 目录除外。

例子:

  • 当前站点:oldsite.olddomain.example
  • 新网站:newdomain.example

所以我知道我可以创建一个 .htaccess 重定向条目来执行此操作,并且它有效,但我想要一个例外 - 我不想重定向特定目录。我仍然希望这个工作:

http://oldsite.olddmain.example/myspecialdirectory/… 及其下的每个文件和目录。

有人可以帮忙吗? 谢谢!

【问题讨论】:

    标签: apache .htaccess redirect


    【解决方案1】:

    oldsite.olddomain.example 的文档根目录中的 .htaccess 文件中尝试此 mod_rewrite 规则:

    RewriteEngine on
    RewriteRule !^myspecialdirectory($|/) http://newdomain.example%{REQUEST_URI} [L,R=301]
    

    【讨论】:

      猜你喜欢
      • 2017-05-13
      • 2015-08-22
      • 2017-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多