且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-11-15 13:09:58

似乎您的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.