I need to change nginx config in a way , that every dynamically generated request is being redirected to main domain.
I'm not sure how to achieve this. Help please!
Not sure if this matters, but I want to add, that traffic goes thru nginx reveser proxy (ssl) to simple web server (nginx)
https://mypage.com/something ->https://mypage.com
https://mypage.com/anything123 ->https://mypage.com
https://mypage.com/randomtext ->https://mypage.com
Best Answer
You could have two location blocks, one for exact match of root directory and the other one for everything else.
rewrite
also can be used instead ofreturn
(redirect), but will be slower.Another option is just to have a
rewrite
for everything (inside server block), without any location blocks. In this method, url will remain as the original url you typed on the browser.