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问题咯

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题