【发布时间】:2021-05-21 14:34:52
【问题描述】:
我安装了新的 laravel 项目(“Starter”)并想通过输入这个 URL 来查看“欢迎”页面。
http://localhost/starter/
当路由如下时页面运行良好。
Route::get('/', function () {
return view('welcome');
});
但是,当我在 (/) 之后写任何东西时...
Route::get('/test', function () {
return view('welcome');
});
并通过网址查看:
http://localhost/starter/test
页面不工作并显示...
404 Not Found
有什么想法吗?
【问题讨论】:
-
尝试运行
php artisan route:list并显示输出 -
这里
http://localhost/starter/test/starter来自哪里?应该是http://localhost/test -
C:\xampp\htdocs\Starter>php artisan route:list +--------+---------+------- ---+--------+---------+------------+ |域名 |方法 |网址 |姓名 |行动 |中间件 | +--------+----------+----------+------+---------+- ------------+ | |得到|头| / | |关闭 |网站 | | |得到|头| api/用户 | |关闭 |接口 | | | | | | |身份验证:api | +--------+----------+----------+------+---------+- ------------+
-
也许你需要使用localhost/starter/public/test
-
我从 URL 中删除了“公共”路径
标签: php laravel url routes backend