redirect to http depending on condition

Viewed 18

I use nginx

Assume that url hello.test.example.com, hello example of dynamically subdomain, how can i redirect to hello.test2.example.com when hello file existing in specific directory path

server_name ~^(?<subdomain>[^.]+)\.test\.example\.com$;
    set $m_file /home/files/$subdomain;
    if (-f $m_file) {
           rewrite ^/(.*)$ http://$subdomain.test2.example.com/;
    }

this condition working when the url (hello.test.example.com) but when the url (hello.test.example.com\en) working but not every time ! why ?

0 Answers
Related