nginx - 我的是lnmp环境,使用thinkphp,这样访问出现了这个?
PHP中文网
PHP中文网 2017-04-11 10:20:54
[PHP讨论组]

是不是我的nginx的配置问题

PHP中文网
PHP中文网

认证0级讲师

全部回复(3)
巴扎黑

这个是URL重写的问题.

如果是apache就不会出现这问题了.因为apache支持.htaccess,在.htaccess中TP官方已经帮你写好了重写规则

但是在Nginx中不支持.htaccess只能自己去写重写规则.

可以用try_files来实现URL重写.
下面这是我的laravel项目重写,你可以参考下!

 location / {
            try_files $uri $uri/ /index.php?$query_string;
        }

全部Nginx配置

server
    {
        listen 80;
    #listen [::]:80;
    server_name yourdomain.com;
        index index.php index.html index.htm  default.html default.htm default.php;
        root  /home;#你的项目下能直接访问到Index.php入口文件的目录
        #如我的index.php在/home/index.php则这里配置到/home;

        include other.conf;
        #error_page   404   /404.html;
        include enable-php.conf;

        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log /home/access.log; #成功访问日志地址如:/home/access.log;
    }

具体详细的你可以百度nginx URL重写!

参考资料:
百度搜索 google搜素

迷茫

没有配置rewrite重写,去掉index.php

天蓬老师

要么是TP的url模式问题
要么是nginx没有做index.php的rewrite问题咯

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号