原来的配置
关于laravel路由设置,官方是这样说的,
Nginx

If you are using Nginx, the following directive in your site configuration will direct all requests to the index.php front controller:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
于是在nginx.conf文件中做了如下配置
重点是这行
location / {
try_files $uri $uri/ /index.php?$query_string;
}
在 vhost目录中的网站218.22.250.70.conf文件中配置如下
Route::get('test',function(){
echo 'key';
});
Route::get('/', function () {
return view('welcome');
});
Route::get('foo', function () {
return 'Hello World';
});
结果是这这样的
看来只有218.22.250.70/ 这个网站根目录路由才可以,其它都弗成,为什么?
修正的配置
终于有一天,
location / {
try_files $uri $uri/ /index.php?$query_string;
}
如图
再次重启nginx后访问218.22.250.70/foo,终于如愿以偿的涌现了期望的界面
至此,宝塔面板下laravel的路由设置终于配置精确。
总结
宝塔面板支持创建多个网站,在配置nginx时要针对子网站的须要配置好vhost/.conf文件,如上所述,总的nginx.conf文件有的配置并不能继续到vhost/.conf中去。类的继续观点在这里不起浸染。