301 Redirect vs 301 RedirectMatch

I was recently tasked with redirecting a url, pretty straightforward I thought.

I said that was easy. But the issue was the trailing slash – this character had to be optional.

In your .htaccess file…


Redirect 301 /page-1/ /page-2/

Introducing RedirectMatch. With RedirectMatch, we can utilize regular expressions to capture a trailing slash or non-trailing slash scenario.


RedirectMatch 301 (?i)/page/?$ https://site.com/page/

The question mark “?” here means, “hey I’m optional”. In this case, the url can be both case insensitive followed by a trailing slash (or a non trailing slash).

Written by Alex Mercer

Alex Mercer is a writer and contributor at Project Immerse, covering web design, WordPress, web development, SEO, digital strategy, emerging technology, and the evolving world of the web. His work focuses on practical ideas, useful tools, and approachable guidance that help creators, developers, and business owners build better digital experiences.

Alex writes with a hands-on, curiosity-driven approach, exploring both established web practices and new technologies shaping how websites are designed, built, and discovered.