Question

My URL is: www.domain.com/url/url/+

I want redirect a 301 error to www.domain.com/url//url/

I've tried this method does not work:

RedirectMatch 301 /+(.*)$ http://www.domain.com/$1

nor does:

RedirectMatch 301 /(.*)/(.*)/+(.*)  http://www.domain.com$1

What method could I use? To cut the + in www.domain.com/url/+ to make it show www.domain.com/url?

Was it helpful?

Solution

You can use this rule to remove + from anywhere in an URI:

RedirectMatch 301 ^/(.+?)\+(.*)$ /$1$2

OTHER TIPS

Hence RedirectMatch uses Regex, + is ment for one or more of the char infront of it. You should use + instead.

The + needs to be escaped because it's a reserved character for "one or more":

RedirectMatch 301 ^/(.*)\+ http://www.domain.com/$1
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top