Reputation: 53
When I re-did my web site years ago, some old straggler pages were left in the old format. So I wrote redirects in the htaccess to send them to new the pages. Problem is the old url's added a character to the end of the main variable that I no longer use anymore. How would I go about removing that character, it's either an "r" or a "p?" Here's an example of one of my redirect's.
RedirectMatch 301 /season-stats-regular-season-(.*)\.html https://www.lakerstats.com/season-stats/?seasonid=$1
So it redirects the page:
https://www.lakerstats.com/season-stats-regular-season-5960r.html
to:
https://www.lakerstats.com/season-stats/?seasonid=5960r
Problem is, I need that "r" removed, so that it goes to:
https://www.lakerstats.com/season-stats/?seasonid=5960
What can I write to remove that "r" in the redirect code? It could also be a "p" as well as I said.
Thanks!
Upvotes: 1
Views: 59
Reputation: 785128
You can use this rule:
RedirectMatch 301 ^/season-stats-regular-season-(.+)r\.html$ /season-stats/?seasonid=$1
Make sure to clear your browser cache before testing this change.
Upvotes: 1