首页 » 网站建设 » phpfrontcontroller技巧_浮屠面板下laravel路由设置踩坑记

phpfrontcontroller技巧_浮屠面板下laravel路由设置踩坑记

访客 2024-12-13 0

扫一扫用手机浏览

文章目录 [+]

原来的配置

关于laravel路由设置,官方是这样说的,

phpfrontcontroller技巧_浮屠面板下laravel路由设置踩坑记

Nginx

phpfrontcontroller技巧_浮屠面板下laravel路由设置踩坑记
(图片来自网络侵删)

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中去。
类的继续观点在这里不起浸染。

标签:

相关文章

小陈聊IT,科技赋能,共创未来

在信息时代,科技的发展日新月异,它已经成为推动社会进步的重要力量。今天,让我们跟随小陈,一起探讨科技赋能,共创美好的未来。一、科技...

网站建设 2024-12-15 阅读0 评论0