nginx - 我的是lnmp环境,使用thinkphp,这样访问出现了这个?
本文介绍了nginx - 我的是lnmp环境,使用thinkphp,这样访问出现了这个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
是不是我的nginx的配置问题
解决方案
这个是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重写!
这篇关于nginx - 我的是lnmp环境,使用thinkphp,这样访问出现了这个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文