gpt4 book ai didi

Laravel 404 错误与 xampp

转载 作者:行者123 更新时间:2023-12-02 10:13:30 25 4
gpt4 key购买 nike

我开始学习如何使用 Laravel,但遇到了问题。当我访问: http://localhost/testing/public/我得到一个工作页面,但是当我输入例如 http://localhost/testing/public/home 时这是我的观点之一,我收到了 404 错误。有人知道如何解决这个问题吗?

编辑:我正在使用最新版本的 laravel,当我这样做时:

Route::view('/home', 'home');

在我的routes/web.php 中我收到该错误

最佳答案

这更可能是虚拟主机的问题,请尝试以下操作:

  • 首先编辑您的路线:Route::get('/home', function(){echo
    "hello"});
  • 然后尝试访问:http://localhost/testing/public/index.php/home

如果它有效,那么肯定是因为您没有虚拟主机,您可以在 Xampp 配置中轻松设置它并修改您的主机文件

  • 首先转到C:\Windows\System32\drivers\etc\hosts并添加一个新的行如:127.0.0.1 yoursite.local
  • 然后转到xampp安装的位置 xampp\apache\conf\extra\httpd-vhosts.conf
  • 然后在文件底部添加虚拟主机,例如:

<VirtualHost *:80>

DocumentRoot "PATH_to_laravel_folder/public"  

ServerName yoursite.local

</VirtualHost>

  • 然后您可以通过输入以下内容访问您的路线:yoursite.local/home或者yoursite.local:80/home

希望对你们有帮助:)

关于Laravel 404 错误与 xampp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46113883/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com