OPNsense Forum

Archive => 24.1, 24.4 Legacy Series => Topic started by: cloudsense on April 11, 2024, 03:57:24 PM

Title: multi domain URL rewrite nginx help
Post by: cloudsense on April 11, 2024, 03:57:24 PM
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
Title: [SOLVED] Re: multi domain URL rewrite nginx help
Post by: cloudsense on April 24, 2024, 06:29:27 PM
figured it out :)
Title: Re: multi domain URL rewrite nginx help
Post by: Monviech (Cedrik) on April 24, 2024, 06:45:07 PM
(https://imgs.xkcd.com/comics/wisdom_of_the_ancients.png)