LARAVEL 5.2找不到路由对象


LARAVEL 5.2 Routing Object Not Found

我通常将开发laravel与artisan一起使用,但在这种情况下,我必须在lampp中设置laravel。我有类似的路线

Route::group(['middleware' => 'cors', 'prefix' => 'service'], function () {
  Route::group(['prefix' => 'master'], function () {
    Route::resource('produk', 'Master'ProdukController');
    Route::resource('agama', 'Master'AgamaController');
  });
Route::resource('list-generic', 'ListGeneric', ['only' => ['index']]);
});

和公用文件夹中的.hta访问:

<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]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

我的问题是。当我访问这个链接时:

http://172.16.16.1/a-web/service/list-generic?select=id

它完美地工作,但是当我用这个链接访问列表后的"/"通用:

http://172.16.16.1/a-web/service/list-generic/?select=id

显示未找到错误对象,请帮忙。。

这一定是因为您的路由文件
添加
Route::resource('list-generic', 'ListGeneric', ['only' => ['index']]);
时Laravel将只使用路线

http://172.16.16.1/a-web/service/list-generic

而不是

http://172.16.16.1/a-web/service/list-generic/

要使上述路由工作,您必须将可选参数添加到route

Route::resource('list-generic/{?query}', 'ListGeneric', ['only' => ['index']]);

此路由将处理所有这两种类型的链接。

我已经为自己的问题找到了解决方案。最后,我必须编辑.httaccess文件:

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