php - 找不到 Laravel 5.1 路由对象

标签 php .htaccess laravel frameworks xampp

请帮助我,我正在使用最新版本的 xampp 开发 Laravel 并且不知道问题的原因是什么。

这条路线工作正常:

Route::get('/', function () {
    return 'aa';
});

此路由给出错误“找不到对象!”:

Route::get('about', function () {
    return 'aaa';
});

httpd.vhosts:

<VirtualHost test.loc:80>
   DocumentRoot "C:/xampp/apps/test.loc/public"
   ServerName test.loc
   <Directory "C:/xampp/apps/test.loc/public">
            #AllowOverride All - when I use this, I get a "Access forbidden!" for all routes
        Require all granted - this works for the main route, other routes give "errors".
</Directory>

/public/.htaccess:

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

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301

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

最佳答案

我遇到了完全相同的问题,但最终这对我有用。

.....
<Directory "C:/xampp/apps/test.loc/public">
   Options Indexes FollowSymLinks Includes ExecCGI
   AllowOverride All
   Require all granted
</Directory>

关于php - 找不到 Laravel 5.1 路由对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31814576/

相关文章:

apache - 从 mod_rewrite 中转义等号、加号和斜杠

.htaccess - Htaccess 重写规则文件扩展名

jquery - Laravel,jQuery 文件上传错误 - "Call to a member function store() on array"

laravel - 未定义路由时 Laravel 如何创建 404 View

javascript - 使用不使用ajax的jquery从数据库中获取php数据

PHP插入到mysql

php - ZF2如何监听特定controller的dispatch事件

javascript - TinyMCE 字段中的脚本标签未正确保存

apache - 如何使用 htaccess 重定向图像更改路径?

mysql - 无法添加外键约束 [Laravel 5.6]