扫码关注官方订阅号
是不是我的nginx的配置问题
认证0级讲师
这个是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问题咯
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
这个是URL重写的问题.
如果是apache就不会出现这问题了.因为apache支持.htaccess,在.htaccess中TP官方已经帮你写好了重写规则
但是在Nginx中不支持.htaccess只能自己去写重写规则.
可以用try_files来实现URL重写.
下面这是我的laravel项目重写,你可以参考下!
全部Nginx配置
具体详细的你可以百度nginx URL重写!
参考资料:
百度搜索 google搜素
没有配置rewrite重写,去掉index.php
要么是TP的url模式问题
要么是nginx没有做index.php的rewrite问题咯