Apache RedirectMatch, which regex to ignore if a keyword is in the URL

Viewed 37

Apache RedirectMatch, which regex to ignore in some cases?

Hi everyone,

I have a RedirectMatch that allows me to redirect domain-one.com to domain-two.com based on the language parameter in the URL.

For example :

https://domain-one.com/en/*

-->

https://domain-two.com/en/*

I use this Apache condition:

<If "%{HTTP_HOST} == 'domain-one.com'">
    RedirectMatch 301 ^/en/(.*)$ https://**domain-two.com**/en/$1
</If>

I would like to know what Regex I should put to ignore this redirect if a very specific keyword is in the base url, for example :

https://domaine-one.com/en/**connect**/*

I tried this expression and it works, but only if the URL ends with "connect", it does not work if the URL is for example "/en/connect/page1" :

RedirectMatch 301 ^/(?!.*connect$)(.*)$ https://domain-two.com/$1

I don't want to redirect if the word "connect" is present in the URL.

I'm not an expert in Regex I admit...

Does anyone have an idea?

Thanks a lot in advance

0 Answers
Related