打开宝塔面板,找到你要配置路由的网站并找到配置文件(如图1)
(图1)
2.在配置文件里添加一下代码
set $root = /www/wwwroot/www.blogs.test/public; #当前应用的运行目录
location ~ \.php {
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
{
root $root;
}
location / {
root $root;
index index.html index.php;
if ( -f $request_filename) {
break;
}
if ( !-e $request_filename) {
rewrite ^(.*)$ /index.php/$1 last;
break;
}
}
3.配置完成后,保存并重载配置和重启Nigx即可
原文:https://www.cnblogs.com/studyandstudy/p/11460232.html