homestead中定制nginx 配置TP隐藏index.php

解决部署网站后不带index.php不能正常跳转字页面的问题:

一.找到homestead安装目录根目录,选择scripts目录,找到serve-xxx.sh,然后复制一份出来,改成自定义的名字如:serve-mcms,然后在该文件中加入如下配置:

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

homestead中定制nginx 配置TP隐藏index.php

二.去homestead引入这个文件,引入是使用type关键字:

homestead中定制nginx 配置TP隐藏index.php

三.重启homestead

homestead中定制nginx 配置TP隐藏index.php

推荐使用工具:Vagrant,相当便捷

四.检查nginx配置

homestead中定制nginx 配置TP隐藏index.php

homestead中定制nginx 配置TP隐藏index.php

到此结束