Laravel快速入门指南路线不起作用 [英] Laravel quick start guide route not working

查看:52
本文介绍了Laravel快速入门指南路线不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我是Laravel的新手,所以直接进入文档开始学习.文档中存在大量漏洞,因此需要花费很多精力和精力来填补空白,以便进行Laravel设置.现在,我已经设置好了它,然后继续进行快速入门指南中的下一步.我创建了路线

Ok I'm new to Laravel so went straight to the documentation to get started. There are massive holes in the documentation so it took a lot of effort and googling to fill the gaps in order to get Laravel set-up. I now have it set up and moved on to the next step in the quick start guide.I created my route

Route::get('users', function()
{
     return 'Users!';
});

现在它说:

Now, if you hit the /users route in your web browser, you should see Users!

所以我上来了:

http://localhost/laravel/users 

但是得到404?我尝试过

but get a 404? I tried

http://localhost/laravel/public/users 

但仍然是404?我遵循了这封信的快速入门指南中的步骤,我想念的是什么?

but still a 404? I followed the steps on the quick start guide to the letter, what am I missing?

推荐答案

似乎您的Laravel应用可以通过Apache HTTP别名访问,因为您的URL类似于:http://localhost/laravel/.如果是这种情况,并假设 http://localhost/laravel指向您的公共目录,请按照下列步骤操作:

Seems like your Laravel app is accesible via an Apache HTTP alias, because your URL looks like: http://localhost/laravel/. If this is the case and assuming that http://localhost/laravel is pointing to your public directory, then follow these steps:

  1. 尝试导航到所需路线,并在/index.php/之前加上/index.php/.如果它可以正常工作(否404),则说明您的问题是Apache HTTP的重写模块配置,您应该执行以下步骤.
  2. 编辑文件public/.htaccess.
  3. RewriteEngine On行下添加RewriteBase /laravel/.
  4. 尝试导航到现有路线.
  1. Try to navigate to your expected route prepend it with /index.php/, in your case: http://localhost/laravel/index.php/users. If it works (no 404) then you problem is with the Rewrite Module configuration of Apache HTTP, you should follow the next steps.
  2. Edit the file public/.htaccess.
  3. Under the line RewriteEngine On add RewriteBase /laravel/.
  4. Try to navigate to an existing route.

基本上,如果您的应用程序位于别名或虚拟目录(例如http://localhost/alias)中,则应在重写规则中添加一个条目,以使用alias重写基本目录.

Basically, if you app resides in a alias or virtual directory (say http://localhost/alias) you should add an entry in your rewrite rule to rewrite the base directory with alias.

这篇关于Laravel快速入门指南路线不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆