centos下搭建的lnmp环境 访问的时候 出现
404 Not Found nginx
这是伪静态问题,解决方法如下:
修改文件: vim /usr/local/nginx/conf/nginx.conf 增加红色标记部分
#ThinkPHP REWRITE支持
```
location / {
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
```
个人项目nginx配置项目实例代码(解决伪静态,服务器500错误)
```
server {
listen 80 default_server reuseport;
server_name _;
root /home/wwwroot/tp6/public;
index index.php index.html index.htm;
location / {
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php$ {
root /home/wwwroot/tp6/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
```