Laravel除Root之外,无法访问其他路由(使用XAMPP)

时间:2018-12-06 00:30:35

标签: php laravel routes xampp

我刚刚开始使用Laravel(v5.7),并且试图将其设置为在虚拟主机中运行(我正在使用Windows的XAMPP软件包)。

为简化起见,唯一起作用的Routeget('/', ...)。其他路由,例如get('/other', ...)失败,并显示错误404 。其他路由仅在运行php artisan serve服务器时才可访问,因此我可以使用端口8000。

但是,我希望Apache在无需识别端口的情况下处理请求。简单吗?

以下是我正在使用且无法正常工作的非常简单的代码(没有控制器):

// ROUTE in routes/web.php
Route::get('/', function() {
    return view('home');
});
Route::get('/other', function() {
    return view('other');
});

注意:我确实在home.blade.php目录中都有视图文件other.blade.phpresources/views

3 个答案:

答案 0 :(得分:0)

XAMPP无法创建非常干净的URL。
您必须将路由指向公用文件夹,而不是应用程序根目录。
因此,而不是theme
尝试panel.spacing.x

答案 1 :(得分:0)

更改路由文件时,应运行此工匠命令php artisan route:cache,以清除路由缓存。

你能试试我的吗?

答案 2 :(得分:0)

遇到相同的错误,您可以尝试使用php artisan来解决问题

或者您可以尝试在以下文件中设置主机 C:\ xampp \ apache \ conf \ extra \ httpd-vhosts.conf和

C:\ Windows \ System32 \ drivers \ etc \ hosts