小编ant*_*gus的帖子

如何使用NGINX从url中删除.php和.html扩展名?

我希望我的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位置添加类似的东西,但没有任何成功.

有什么建议吗?

html php nginx

39
推荐指数
4
解决办法
5万
查看次数

标签 统计

html ×1

nginx ×1

php ×1