在laravel 4.2中没有index.php的路由不起作用


Routes not working without index.php in laravel 4.2

尽管之前在xampp服务器上的Laravel 4.2中设置了几个测试项目,但我还是花了大量时间在谷歌上搜索相关建议。我不确定我在这个项目中遗漏了什么。。。

我在服务器上还有一个项目,它运行得很好,但当我试图启动这个新项目时,我开始遇到这个错误。

XAMPP版本5.6.3PHP版本5.6.3

这是我的.htaccess文件:

RewriteEngine on

选项-多视图上的重写引擎

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [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';
});

我的网址是:http://localhost/adminpanel/public/admin

并显示此错误:

Symfony''Component''HttpKernel''Exception''NotFoundHttpException

当我写这个网址时:http://localhost/adminpanel/public/index.php/admin现在运行良好。。

在您的公用文件夹上尝试此htaccess

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]