Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

location block, redirect all but specific domain with any subdomain and any path

$
0
0
I am trying to do a redirect using location regex.I want everything to be redirected to 404 exept from the examplesite.com with every possible path and subdomain.examplesite.com should be redirected to my server.

examplesite.com redirect
https://m.examplesite.com redirect
www.examplesite.com/something redirect
everything else redirect to 404

This is my config:



location ~ ^(?!(.?)examplesite.com/?(.*)) {
return 404;
}

location / {
return 302 $scheme://192.168.1.1/index.html; #this is a local web server
}

which must be wrong because it redirects every examplesite.com i tried to 404.

Viewing all articles
Browse latest Browse all 4759

Trending Articles