TP5框架 nginx服务器 配置域名 隐藏index.php

自闭症网瘾萝莉.ら 提交于 2019-12-19 16:17:42
server {
        listen       80;
        #server_name  localhost;
    server_name  hhy.com;/**这里写自己的域名*/

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        # root    "F:/PHPstudy/PHPTutorial/WWW";
    root    "F:/PHPstudy/PHPTutorial/WWW/ShopMall";

        location / {
            index  index.html index.htm index.php l.php;
            /**下面的if判断就是隐藏index.php*/
        if (!-e $request_filename) {
            rewrite  ^(.*)$  /index.php?s=/$1  last;
            break;
            }
           autoindex  off;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

nginx服务器的配置文件是 nginx.conf ,注意配置文件的最后是否有加载其他配置文件

打开我的电脑,目录是C:\Windows\System32\drivers\etc下的hosts文件,在最下面加上127.0.0.1 hhy.com,添加的域名一定要跟nginx的配置文件中设置的域名一致

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!