17

I'm unable to find how I can map a single URL to a single static file. I tried:

location /feeds/seznam/ {
    alias /path/to/file/feed.xml;
}

but this does not work (in logs I see that it appends index.html to the path).

1
  • This answer for new readers
    – user21904
    Commented Sep 19, 2015 at 10:23

1 Answer 1

16

Try this instead:

location /feeds/seznam/ {
    rewrite ^/feeds/seznam/$ /path/to/file/feed.xml;
}

References

3
  • 2
    Working, but /path/to/file.xml must be the URL path, not a filesystem path.
    – Bruce
    Commented Aug 8, 2013 at 8:03
  • @Bruce - can you give me an example?
    – slm
    Commented Aug 8, 2013 at 8:07
  • 2
    @slm, you're looking for alias /your-file-path; -- nginx.org/en/docs/http/ngx_http_core_module.html#alias
    – jobwat
    Commented Feb 7, 2017 at 0:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .