【问题标题】:Routes not working without index.php in laravel 4.2在 laravel 4.2 中没有 index.php 的路由不起作用
【发布时间】:2015-04-12 19:36:40
【问题描述】:

尽管之前在 xampp 服务器上在 Laravel 4.2 中设置了几个测试项目,但我已经花费了大量时间在谷歌上搜索建议。 我不确定我在这个项目中缺少什么......

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

XAMPP 版本 5.6.3 PHP 版本 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? (AllowOverride All)
  • @lukasgeiter,是的,它已经启用了..

标签: php apache .htaccess laravel-4


【解决方案1】:

在你的公用文件夹上试试这个 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]

【讨论】:

    猜你喜欢
    • 2014-03-06
    • 2016-02-29
    • 2016-02-27
    • 2014-08-26
    • 2017-10-31
    • 2017-07-20
    • 1970-01-01
    • 2016-11-05
    相关资源
    最近更新 更多