Forum Topic: Redirecting for slashes and without slashes
Let’s say I had a page named pancakes on my site but I’ve deleted it and want to redirect to my home page. I want to make sure that people who have entered
/pancakes will be redirected.
Previously, I’ve done the below:
Redirect 301 /pancakes/ http://example.com Redirect 301 /pancakes http://example.com
Now I want to have one line instead of two. Which of the below rules is the correct one?
RedirectMatch 301 /pancakes/?$ http://example.com RedirectMatch 301 /pancakes(.*) http://example.com
2 Replies to “Redirecting for slashes and without slashes”
It depends on which case you’re after:
/pancakes/?$ will match only the following URLs:
On the other hand,
/pancakes(.*) matches much more, such as:
http://example.com/pancakes http://example.com/pancakes/ http://example.com/pancakes/something http://example.com/pancakes/something/else/ http://example.com/pancakes/anything/else/
So it depends, basically, on whether you’re also redirecting any sub-content.
Thanks for explaining.