【问题标题】:Apache redirect阿帕奇重定向
【发布时间】:2010-11-20 16:14:23
【问题描述】:

我想在 Apache 中使用 RedirectMatch 重定向 URL,例如,

/test/one/??重定向到 /test/two/??

在哪里??表示后面的任何字符串

我在下面使用的重定向执行直接重定向,但在...之后不匹配任何字符串 RedirectMatch Permanent ^/test/one?$ /test/two/

非常感谢

【问题讨论】:

    标签: apache redirect


    【解决方案1】:
    RewriteEngine ON
    RewriteBase /
    RewriteRule ^/test/one/(.+)$ /test/two/$1
    

    如果这不起作用,请将 ^/test/one 更改为 ^test/one

    确保 mod_rewrite 已启用

    【讨论】:

      【解决方案2】:

      您可以为此使用 mod_rewrite:

      RewriteEngine On
      RewriteBase /
      RewriteRule ^/test/one/(.*) /test/two/$1 [L,R=301]
      

      R 标志重定向页面,而不是在内部重写 URI。 301 是“永久移动”的 HTTP 状态代码 - 如果您想使用另一个,可以将其更改为 one of these

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-08-21
        • 2017-02-11
        • 1970-01-01
        • 2018-07-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多