【问题标题】:Removing a character from a redirect URL in htaccess从 htaccess 中的重定向 URL 中删除字符
【发布时间】:2021-01-10 01:36:01
【问题描述】:

当我几年前重新制作我的网站时,一些旧的散乱页面以旧格式留下。所以我在 htaccess 中编写了重定向以将它们发送到新页面。问题是旧网址在我不再使用的主要变量的末尾添加了一个字符。我将如何删除该字符,它是“r”还是“p”?这是我的重定向之一的示例。

RedirectMatch 301 /season-stats-regular-season-(.*)\.html https://www.lakerstats.com/season-stats/?seasonid=$1

所以它重定向页面:

https://www.lakerstats.com/season-stats-regular-season-5960r.html

到:

https://www.lakerstats.com/season-stats/?seasonid=5960r

问题是,我需要删除“r”,以便它转到:

https://www.lakerstats.com/season-stats/?seasonid=5960

我可以写什么来删除重定向代码中的“r”?正如我所说的,它也可以是一个“p”。

谢谢!

【问题讨论】:

标签: regex .htaccess url redirect http-status-code-301


【解决方案1】:

你可以使用这条规则:

RedirectMatch 301 ^/season-stats-regular-season-(.+)r\.html$ /season-stats/?seasonid=$1 

确保在测试此更改之前清除浏览器缓存。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-16
    相关资源
    最近更新 更多