There are several domain names bound to my server.
I need to redirect requests like domain.com
or domain.com/
to app.domain.com
.
Following is what I added in my app config:
server {
listen 80;
server_name main_domain.com domain.com;
... other lengthy directives ...
location = / {
if ($host ~ 'domain.com') {
return 302, http://app.domain.com;
}
}
location / {
try_fies $uri @app;
}
location @app {
include uwsgi_params;
uwsgi_pass unix:path_to/uwsgi.sock;
uwsgi_intercept_errors on;
}
}
This made the redirection works, but requests to /
of my other domain names all returned 404.
What can I do to make Nginx go on matching locations?
return 302, app.domain.com;
---> typo?,
. Another thing : the regex will match*domain.com*
so you should use^domain.com$
instead ofdomain.com
.= /
location block no other location block will apply. It should then be obvious why you're getting a 404 forhttp://other-host.com/
.continue
for this block. I'll try your solution and see if it works :)