multi domain URL rewrite nginx help

Started by cloudsense, April 11, 2024, 03:57:24 PM

Previous topic - Next topic
Hi,

I have location / and one website with multi domain SSL.

the SSL are for  domain.nl domain.fr domain.de domain.eu  etc
what I want to do is something like this.

if url is http( or https)  :// domain.(nl| fr|de| eu), redirect it to https://www.domain.com/$1/$2 ,  where $1 = nl fr de eu etc and $2 is reset of the query string ..
so if url comes to http://domain.nl/abc/123 , it will redirect to https://www.domain.com/nl/abc/123

This is the regex I am using

^(?:(?:http:\/\/|https:\/\/)?(?:www\.)?)?domain\.(nl|fr|de|eu)(\/.*)?$

and the redirect is
https://www.domain.com/$1/$2   

However, this does not work .. I have tried the regex in both location block as well as http server block .

Can someone please help ?


Thanks