0

Nginx has a root folder let's say /var/www/mysite1/

I have a file in /var/www/ that I need to be able to serve. This file sometime exists, sometime does not. If the file is not there, by default nginx is returning a 404. How can I set up a different response code, or a 301 redirection ?

location /myfile.txt { alias /var/www/myfile.txt; } 
7
  • nginx.org/r/error_page Commented Jun 6, 2020 at 5:52
  • serverfault.com/questions/218989/… Commented Jun 6, 2020 at 6:02
  • I know the try uri command, but it tries a url path. My file is in a parent folder of the root so I need to use an alias Commented Jun 6, 2020 at 6:07
  • 2
    Change root and use try_files. Commented Jun 6, 2020 at 7:26
  • I need to change root inside that location block, right? Commented Jun 6, 2020 at 8:45

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.