duanliang789262 2018-12-06 00:30
浏览 285

Laravel无法访问其他路由,但根目录(使用XAMPP)

I have just started using Laravel (v5.7) and I am trying to set it up to work in a virtual host (I'm using the XAMPP package for Windows).

To simplify, the only Route that works is the get('/', ...). Other routes, like get('/other', ...) fails with Error 404. The other routes are only accessable when running the php artisan serve server, so I can use port 8000.

However, I wish Apache was handling the requests, without the need of idenifying the port. Is that simple?

A very straight forward code that I'm using and isn't working follows (without controllers):

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

NOTE: I do have both view files home.blade.php and other.blade.php in resources/views directory.

  • 写回答

3条回答 默认 最新

  • duanmen1887 2018-12-06 08:51
    关注

    XAMPP can't make very clean URLs.
    You have to point your routes to the public folder, not the application root.
    So instead of localhost/MyProject/other
    Try localhost/MyProject/public/other

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?