Reputation: 6203
I have the following directory:
]# ls /srv/web/logs/
yellow-log blue-log log.css
I want to have two links:
example.com/yellow-log
example.com/blue-log
What should the nginx rule look like for this? I've tried:
location ~* ^/(?:yellow|blue)-log(?:/|.html)?$ {
alias /srv/web/logs;
}
but that complains about missing index. I simply want each of those pages to be served when a request is made for them, and both should reside in the same directory. Both use the same log.css
file.
Upvotes: 1
Views: 465
Reputation: 49672
You have half the solution. Problem is you use alias
when you mean root
and you have no path to the CSS file. Assuming the CSS file is relative to the HTML file, it's URI will actually be example.com/log.css
. The log files have no extension and therefore require a default_type
.
One solution is:
location ~* ^/(?:yellow|blue)-log$ {
default_type text/html;
root /srv/web/logs;
}
location = log.css { root /srv/web/logs; }
Upvotes: 1