laravel 4.2 中没有 index.php 的路由无法正常工作

Routes not working without index.php in laravel 4.2

尽管之前在 Laravel 4.2 服务器上的 Laravel 4.2 中设置了几个测试项目,但我还是花了相当多的时间在谷歌上搜索这方面的建议。 我不确定我在这个项目中缺少什么...

我在服务器上还有一个项目,它工作正常但是当我尝试启动这个新项目时,我开始收到这个错误。

XAMPP版本5.6.3 PHP 版本 5.6.3

这是我的 .htaccess 文件:

RewriteEngine on

选项 - 多视图 重写引擎开启

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ / [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

这是我的 Routes.php 文件:

Route::get('/admin', function(){
    echo 'hello';
});

我的 url 是: http://localhost/adminpanel/public/admin

并显示此错误:

Symfony\Component\HttpKernel\Exception\NotFoundHttpException

当我写这篇文章时 url : http://localhost/adminpanel/public/index.php/admin 现在工作正常..

在您的 public 文件夹上试试这个 htaccess

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ / [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]