Nginx 环境怎么隐藏 thinkphp5 入口 index.php?

2019-03-1010:03:18服务器及运维Comments2,464 views字数 364阅读模式

打开Nginx.conf文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9892.html

找到 server {}里的:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9892.html

        location / {
            index  index.html index.htm index.php l.php;
           autoindex  off;
        }

替换为:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9892.html

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

如果你的ThinkPHP安装在二级目录,Nginx的伪静态方法设置如下,其中youdomain是所在的目录名称。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9892.html

location /youdomain/ {
    if (!-e $request_filename){
        rewrite  ^/youdomain/(.*)$  /youdomain/index.php?s=$1  last;
    }
}

PS:做以上配置后还需要把首页访问入口指向public目录,否则不会成功。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9892.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/yunwei/9892.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定