我希望我的nginx make显示所有url的干净.
通过一些研究,我已经将第一个案例付诸实践.它通过以下配置完成:
location / {
root html;
index index.html index.htm index.php;
try_files $uri.html $uri/ =404;
}
Run Code Online (Sandbox Code Playgroud)
它适用于indexhtml.html显示为indexhtml,但.php没有任何反应.如果我将$ uri.html更改为$ uri.php,它既不适用于.html,也不适用于.php.我试图在php位置添加类似的东西,但没有任何成功.
有什么建议吗?
我在nginx中设置这个别名以正确显示我的网站时遇到了很多麻烦.
我关注的网站应该可以访问,mywebsite.com/mr并且与位于的网站不同mywebsite.com/.该网站位于/fullpath(为简单起见缩短)该网站需要提供三种内容:
/fullpath/index.html..html浏览器中显示扩展名)./fullpath和子目录中.我已经尝试改变比赛的顺序,try_files并找到了他们都工作的情况,但不是在同一时间:
location /mr {
default_type "text/html";
alias /fullpath;
# with this one 1 and 3 work
# try_files $uri/index.html $uri.html $uri;
# with this one 2 and 3 work
# try_files $uri $uri.html $uri/index.html;
# with this one 1 and 2 work
try_files $uri.html $uri/index.html $uri;
}
Run Code Online (Sandbox Code Playgroud)
当一个人不工作时404.有谁知道我怎么能正确地提供各种文件?