从htaccess中的重定向URL中删除字符

问题描述

几年前,当我重新创建网站时,一些旧的散乱页面以旧格式保留。因此,我在htaccess中编写了重定向,以将其发送到新页面。问题是旧的url在我不再使用的main变量的末尾添加了一个字符。我将如何删除该字符,它是“ 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”。

谢谢!

解决方法

您可以使用以下规则:

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

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

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...