Laravel 5.1 Route Object not found

丶灬走出姿态 提交于 2019-12-01 08:42:09

问题


Please help me, I'm working on a Laravel using the latest version of xampp & do not know what the cause of my problem is.

This route is working fine:

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

This route gives an error "Object not found!":

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]


回答1:


I faced exactly the same problem, but finally this worked for me.

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



回答2:


Add this to your httpd.vhosts file

<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>



回答3:


Have you tried adding a slash before the name? like this:

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


来源:https://stackoverflow.com/questions/31814576/laravel-5-1-route-object-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!