Nginx 隐藏入口文件index.php

为了美化路由和处于安全考虑,我们通常会隐藏项目的入口文件比如 index.php,在Nginx服务配置文件nginx.confserver域的location里面加入如下代码:

https://dzt666.cn/usr/uploads/2020/04/20200403103159.png

if (!-e $request_filename) {
    rewrite  ^/(.*)$  /index.php/$1  last;
    break;
}

https://dzt666.cn/usr/uploads/2020/04/20200403103257.png

如果配置文件的目录下有vhosts.conf的话,在nginx.conf里面改可能不起作用,得找到对应配置文件的对应位置加上才行,改完之后别忘了重启nginx

Last modification:April 3rd, 2020 at 10:52 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment