【问题标题】:Apache htaccess exclude specific URL from 301-redirectApache htaccess 从 301 重定向中排除特定 URL
【发布时间】:2016-05-27 11:08:02
【问题描述】:

在 apache 系统上,我使用这个 .htaccess 添加了从旧服务器到新服务器的重定向:

redirect 301 / http://www.new-domain.com/redirect.php?q=

但我想排除此 URL 的重定向:

http://domain.com/index.php/admin/

在 URL“/index.php/admin”中包含此部分的旧管理区域的每个请求都应保留在旧服务器上,并且不会被重定向到新服务器。

如何实现?

【问题讨论】:

    标签: php apache .htaccess redirect


    【解决方案1】:

    您可以使用mod_rewrite 规则代替不允许正则表达式的Redirect

    RewriteEngine On
    
    RewriteRule !^index\.php/admin http://www.new-domain.com/redirect.php?q=%{REQUEST_URI} [L,NE,R=302]
    

    【讨论】:

      【解决方案2】:

      您可以将Redirect 指令包装在If

      <If %{REQUEST_URI} != "/index.php/admin/">
          Redirect ...
      </If>
      

      【讨论】:

        猜你喜欢
        • 2018-01-22
        • 1970-01-01
        • 1970-01-01
        • 2018-04-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-23
        相关资源
        最近更新 更多