【问题标题】:Url redirect using .htaccess from old url links to new url links使用 .htaccess 从旧 url 链接到新 url 链接的 URL 重定向
【发布时间】:2015-08-04 10:23:35
【问题描述】:

使用 .htaccess 从旧 url 链接到新 url 链接的 URL 重定向 我想从 http://www.example.net/abc/abc-post/item/123-abc-xyzhttps://www.example.net/abc/index.php/123-abc-xyz

我尝试了以下代码,但它在 .htaccess 中不起作用

redirect 301 http://www.example.net/abc/abc-post/item/123-abc-xyz https://www.example.net/abc/index.php/123-abc-xyz.

【问题讨论】:

    标签: php apache .htaccess mod-rewrite redirect


    【解决方案1】:

    您不能在 URI 模式中使用 http:// 和主机名。另外最好使用RedirectMatch,这样您就可以捕获123-abc-xyz并在目标中重用:

    RedirectMatch 301 ^/abc/abc-post/item/(123-abc-xyz)/?$ https://www.example.net/abc/index.php/$1
    

    【讨论】:

      猜你喜欢
      • 2018-10-11
      • 1970-01-01
      • 2016-02-11
      • 2012-09-17
      • 1970-01-01
      • 2016-11-30
      • 1970-01-01
      • 2015-09-14
      • 2022-06-11
      相关资源
      最近更新 更多