Laravel 快速入门指南路线不起作用

2023-10-31php开发问题
0

本文介绍了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/ 导航到您预期的路线,在您的情况下:http://localhost/laravel/index.php/users.如果它有效(没有 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),您应该在重写规则中添加一个条目来重写 基本目录 带有 别名.

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 快速入门指南路线不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17