2 ms·
Naaah... try_files would be better. Something like: location / { ssi on; set $inc $request_uri; ssi_silent_errors on; try_files $uri $uri/ /s
by phillipseamore 4y ago
Naaah... try_files would be better. Something like:
location / {
ssi on;
set $inc $request_uri;
ssi_silent_errors on;
try_files $uri $uri/ /ssi.html;
}
ssi.html:
<html>
<body>
<!--# if expr="$inc" != "/" -->
<!--# include file="$inc.html" -->
<!--# else -->
<!--# include file="inc_index.html" -->
<!--# endif -->
</body>
</html>
- thunderbong 4y agoIf I understand correctly, if I enter the URL example.com/abcd it will look for abcd.html and if doesn't find that it will look for abcd_index.html and finally dail quietly. Did I get that right? Can you elaborate why this is better?
- phillipseamore 4y agotry_files will handle checking if the file already exists, if it doesn't it will use ssi.html which will then handle including the file. If there isn't a request for a specific file, e.g. https://example.com/ https://example.com/, then it will include "inc_index.html" (that's just the string "inc" not a variable "$inc" and I'm comparing to "/" from memory, it might just need to be an empty ""). You could skip the "set $inc $request_uri" line and simply use $uri (that's the normalized URI) in ssi.html.