Jump to content

Help with nginx rule


FD_F

Recommended Posts

Hi,

 

i have many sub domains i need to rewrite 

 

for example:

http://subx.domain.com/i30/index.html

will rewrite to:

/home/domain/live.domain.com/subx/i30/index.html

 

so i did rule:

if ( $host ~ "subx.domain.com" ) {

        rewrite ^(.*) http://live.domain.com/subx/$uri last;

 

    }

 

but i don't want make every time different rule and i need to create  one will take care all the sub domains with the same course

 

any ideas ?

 

thanks!

 

 

 

 

 

Link to comment
Share on other sites

problem solved

 

set $subdomain "";

set $subdomain_root "";

if ($host ~* "^(.+)\.domain\.com$") {

    set $subdomain $1;

    set $subdomain_root "/$subdomain";

    rewrite ^(.*)$ $subdomain_root$1;

    break;

}

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.