【问题标题】:htaccess rewrite removing consecutive numbers in filenameshtaccess rewrite 删除文件名中的连续数字
【发布时间】:2017-09-14 09:56:08
【问题描述】:

我的旧网址包含我喜欢通过 htaccess 重定向的连续数字,例如:

(我还不允许发布链接)

www.example.com/just/another/path2/name-789-e-11-2.html www.example.com/its/another/path3/name-789-e-11-5.html

在新系统上,附加数字不再存在:

www.example.com/just/another/path2/name-789-e-11.html www.example.com/its/another/path3/name-789-e-11.html

所以现在不同路径中的文件名是相同的,没有附加的连续数字。

有人对此有解决方案吗?我尝试了不同的方法,但都没有奏效。

任何帮助将不胜感激。

【问题讨论】:

    标签: .htaccess mod-rewrite


    【解决方案1】:

    您可以将此重定向规则用作站点根目录中的第一条规则 .htaccess:

    RedirectMatch 301 ^/(.+\d+)-\d+\.html$ /$1.html
    

    【讨论】:

    • 完美,非常感谢,这两种情况都有效。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-03
    • 2021-02-22
    相关资源
    最近更新 更多