TP5环境静态文件报404的解决方案
主要还是站点配置文件,找到vhost下的站点配置文件,代码如下
server { listen 80; server_name www.test.com test.com; index index.html index.htm index.php; #include /usr/local/nginx/conf/rewrite/none.conf; root /home/wwwroot/myproject888/;#根目录路径 #error_page 404 = /404.html; #error_page 502 = /502.html; location / { if (!-e $request_filename) { rewrite ^(.*)$ /public/index.php?s=/$1 last; break; } } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index /index.php; include fastcgi_params; fastcgi_split_path_info ^(.+?\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/../:/tmp/:/proc/"; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { root /home/wwwroot/myproject888/public/; #这里一定要设置root路径,不然图片访问报404错误 expires 30d; access_log off; } location ~ .*\.(js|css)?$ { expires 7d; access_log off; } location ~ /\.ht { deny all; } access_log /home/wwwlogs/access.log; }