【问题标题】:.htaccess Redirect Directory To Subdirectory.htaccess 将目录重定向到子目录
【发布时间】:2015-10-08 11:52:11
【问题描述】:

我正在尝试重定向我的页面

http://example.com/category/general/

http://example.com/blog/category/general/

我认为这会起作用,但它最终会无限循环

RedirectMatch 301 /category/general/ /blog/category/general/

【问题讨论】:

    标签: regex .htaccess mod-rewrite redirect subdirectory


    【解决方案1】:

    您也必须使用正则表达式锚:

    RedirectMatch 301 ^/category/general/?$ /blog/category/general/
    

    还有捕获组:

    RedirectMatch 301 ^/(category/general/?)$ /blog/$1
    

    清除浏览器缓存后进行测试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-04
      • 1970-01-01
      • 2019-11-24
      • 1970-01-01
      • 2019-02-19
      • 1970-01-01
      • 2014-08-28
      相关资源
      最近更新 更多