【问题标题】:How to Redirect every link beginning with the same word in .htaccess?如何重定向.htaccess中以相同单词开头的每个链接?
【发布时间】:2020-12-24 15:41:41
【问题描述】:

我需要将大量以相同单词开头的网址重定向到新链接。

示例:

  • 重定向 301 /old-text-1/ /new-link/
  • 重定向 301 /old-text-2/ /new-link/
  • 重定向 301 /old-text-3/ /new-link/
  • 重定向 301 /old-text-4/ /new-link/
  • 重定向 301 /old-text-5/ /new-link/
  • ...

我可以以更好的方式重定向所有这些链接吗?

我试过了:

RewriteRule ^/old-text(.*)$ /new-link/ [R=301,L]

但它不起作用。

【问题讨论】:

    标签: .htaccess redirect


    【解决方案1】:

    .htaccess 上下文中使用RewriteRule 指令时,您需要删除尾部斜杠。

    RewriteRule ^old-text(.*)$ /new-link/ [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-15
      • 1970-01-01
      • 2019-01-29
      • 1970-01-01
      相关资源
      最近更新 更多