March 23, 2011 08:40AM
I've read the whole NginX wiki and couldn't find a solution yet. So would you be so gentle to tell me how to do this.

I have two (2) domains on the same website. Let's say "" and ""
The frontend php shares the same files and the only difference is in the layout so I must differentiate the layout based on the hostname header sent by client.

My goal would be to redirect to the www domain if an invalid subdomain is typed.

example: must redirect to as well as must redirect to

My setup when I was using a single domain was easy:

if ($host !~* "") {
rewrite ^(.*)$$1 permanent;

but now my need is to do something like:

if ($host !~* "|") {
rewrite ^(.*)$ (what to put here???)$1 permanent;

Thanks to anyone able to help me out with this issue...
Subject Author Posted

redirect based on hostname

sevy March 23, 2011 08:40AM

Re: redirect based on hostname

Igor Sysoev March 23, 2011 08:44AM

Re: redirect based on hostname

sevy March 23, 2011 08:47AM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 348
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready