【问题标题】:Laravel not able to load other URLs other than home(/)?Laravel 无法加载除 home(/) 以外的其他 URL?
【发布时间】:2013-10-26 09:44:29
【问题描述】:

我安装了 laravel 并在 localhost/laravel/public 上获取主页。 但是不能做简单的路由。

Route::get('/', function()
{
    return View::make('hello');
});

Route::get('authors',function()
{
    return View::make('hello');
});

在这里,我在 localhost/laravel/public/authors 上调用了相同的视图。 但我得到了 404。

我对@9​​87654324@ 也有不同的看法,但authors 没有

Route::get('/', function()
{
    return View::make('authors');
});

Route::get('authors',function()
{
    return View::make('authors');
});

现在我在/ 上获得作者的观点,但在authors 上没有。

谢谢

【问题讨论】:

  • Apache 安装了吗? ... 启用了mod_rewrite 指令?
  • 看看localhost/laravel/public/index.php/authors是否有效。
  • 它有效localhost/laravel/public/index.php/authors

标签: php routing laravel http-status-code-404


【解决方案1】:

如果您能够访问/laravel/public/index.php/authors,那么您需要将RewriteBase 添加到您的.htaccess 文件中,也就是说,假设您正在运行Apache:

RewriteEngine on
RewriteBase /laravel/public
<other rules go here>

【讨论】:

  • 仍然无法正常工作... .htaccess 文件添加两行后RewriteEngine on RewriteBase /laravel/public &lt;IfModule mod_rewrite.c&gt; Options +FollowSymLinks RewriteEngine On &lt;/IfModule&gt; &lt;IfModule mod_rewrite.c&gt; RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] &lt;/IfModule&gt;
猜你喜欢
  • 2019-05-07
  • 2020-03-09
  • 2013-09-12
  • 2017-12-20
  • 1970-01-01
  • 1970-01-01
  • 2021-12-31
  • 1970-01-01
  • 2018-01-01
相关资源
最近更新 更多