user3722573
user3722573

Reputation: 177

301 redirect if url contains specific string

Didn't found in any of answers this, that's why I'm asking it.

Basically, I need to 301 redirect URL that contains some specific character in it, but dynamically.

Specific character is "/l/"

For example:

 - example.com/l/test should 301 redirect to example.com/test
 - example.com/test/1/2/l/3 should 301 redirect to example.com/test/1/2/3

Basically it means that any url containing "/l/" should be the same url, but without "/l/"

Restrictions:

 - /l/ can be anywhere in url.
 - url is dynamic

Thanks!

Upvotes: 1

Views: 1704

Answers (1)

anubhava
anubhava

Reputation: 784918

You can use this rule in root .htaccess:

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

Upvotes: 1

Related Questions