我希望能够将filename.jade
和filename.styl
作为文字mime类型返回。
nginx
需要提供/source
目录中的任何内容,就好像它是文本
现在使用符号链接
/source/subdir/page1.jade.txt => ../subddir/page1.jade
并在nginx
location ~ ^/source/ {
expires 1d;
try_files $uri.txt 404;
}
这可行,但不是很优雅,并且需要重新创建符号链接
这是如何在nginx
完全实现的?是否有必要使用rewrite
从路径中删除/source
目录?
答案 0 :(得分:1)
最好使用location
指令和types
指令作为示例belove:
location ~ /*.jade {
types { }
default_type text/plain;
try_files $uri =404;
}
location ~ /*.styl {
types { }
default_type text/plain;
try_files $uri =404;
}
这两个location
块都设置为不使用任何MIME类型并使用默认的text/plain
MIME类型,因此它应该适合您。
我希望这会有所帮助