regex for url-encoded characters
-
I was hoping someone might be able to provide a helping hand with a regex query that includes trailing URL-encoded characters. Google Search Console is reporting to our team a lot of instances like the following:
- https://www.example.com/news/local/page/2769/?page=261%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F
- https://www.example.com/news/sports/college/page/284/?page=2%2F%2F%2F
- https://www.example.com/news/sports/national/page/1464/?page=1%2F%2F%2F%2F%2F%2F%2F%2F
Using the first example above, I can easily redirect it to
without the trailing URL-encoded characters involved using this regex (note: I don’t need the redundant
pageURL parameter so I’m clearing it out with the redirect):^/news/local/page/(.*)/\?page=(.*)->/news/local/page/$1/However, I’m not sure how to deal with the undetermined random amount of trailing URL-encoded characters at the end the URL. Any advice here would be highly appreciated!
You must be logged in to reply to this topic.