未找到Laravel 5.1路径对象

时间:2015-08-04 16:29:13

标签: php .htaccess laravel frameworks xampp

请帮助我,我正在使用最新版本的xampp& amp;不知道我的问题是什么原因。

这条路线运转良好:

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]

3 个答案:

答案 0 :(得分:6)

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

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

答案 1 :(得分:1)

将此添加到您的httpd.vhosts文件

<VirtualHost test.loc:80> 

 ServerName test.loc
 DocumentRoot "C:/xampp/apps/test.loc/public"
  <Directory "C:/xampp/apps/test.loc/public">
     Options Indexes FollowSymLinks MultiViews
     AllowOverride All
     Order allow,deny
     allow from all
 </Directory>

答案 2 :(得分:-1)

您是否尝试在名称前添加斜杠? 像这样:

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