我正在尝试使用RESTFULE CONTRORTER。这是我的

问题描述 投票:0回答:9
我是我的

TestController.php



<?php class TestController extends \BaseController { /** * Display a listing of the resource. * * @return Response */ public function index() { return View::make('test.home'); } /** * Show the form for creating a new resource. * * @return Response */ public function create() { // } /** * Store a newly created resource in storage. * * @return Response */ public function store() { // } /** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { // } /** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // } }
我的应用程序路线是
localhost/Test/public/

,它显示了“您到达”的消息。但是,当我尝试时,它给了我“ Symfony \ Component \ httpkernel \ extception \ notfoundhttpexception”

我的日志是:

localhost/Test/public/test
我知道这个问题已经很多次。我经历了许多相关线程,但无法弄清楚解决方案。 

	
laravel中的例外始终意味着它找不到针对particularurl
曲子。在您的情况下,这可能是您的Web服务器配置,虚拟主机(站点)Configuratio或.htaccess Configuration中的问题。 您的公共/.htaccess应该看起来像:

[2014-05-11 14:29:59] production.ERROR: NotFoundHttpException Route: `http://localhost/Test/public/test` [] [] [2014-05-11 14:29:59] production.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in C:\wamp\www\test\bootstrap\compiled.php:5289 Stack trace: #0 C:\wamp\www\test\bootstrap\compiled.php(4663): Illuminate\Routing\RouteCollection->match(Object(Illuminate\Http\Request)) #1 C:\wamp\www\test\bootstrap\compiled.php(4651): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request)) #2 C:\wamp\www\test\bootstrap\compiled.php(4643): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request)) #3 C:\wamp\www\test\bootstrap\compiled.php(698): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request)) #4 C:\wamp\www\test\bootstrap\compiled.php(679): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request)) #5 C:\wamp\www\test\bootstrap\compiled.php(1136): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true) #6 C:\wamp\www\test\bootstrap\compiled.php(7218): Illuminate\Http\FrameGuard->handle(Object(Illuminate\Http\Request), 1, true) #7 C:\wamp\www\test\bootstrap\compiled.php(7815): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true) #8 C:\wamp\www\test\bootstrap\compiled.php(7762): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true) #9 C:\wamp\www\test\bootstrap\compiled.php(10768): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true) #10 C:\wamp\www\test\bootstrap\compiled.php(640): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request)) #11 C:\wamp\www\test\public\index.php(49): Illuminate\Foundation\Application->run() #12 {main} [] []

您可以看到第一行中的条件
NotFoundHttpException

<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] </IfModule>
php laravel laravel-4
9个回答
38
投票
将正常工作,但不是这样:

IfModule mod_rewrite.c
另一方面,这也应该工作,因为这是其原始形式: localhost/Test/public/ 由于Laravel需要重写其工作。

请注意,您不应该使用 /公开,您的URL应该看起来像这样:

localhost/Test/public/test
这是另一个线索,即您的虚拟主机的文档根未正确配置或未指向/var/www/test/public或您的应用程序所处的任何路径。

所有,以假设您正在使用Apache2。


我有这个情况。我检查了所有代码,我的解决方案是:

localhost/Test/public/index.php/test

由于我忘了清除路由缓存。

在我的

localhost/Test/

之前,就像下面
php artisan route:cache

在URLEnterd

HTTP://127.0.0.1:8000/admin/roles

获取相同的错误。解决方案是:


15
投票
themove“ prefix'=>'admin',因为两个控制器都位于管理文件夹中

就像Arjan Koole说,我有类似的错误

使用:


2
投票



Route::group(['middleware' => ['role:admin']], function() { Route::resource('roles','Admin\RoleController'); Route::resource('users','Admin\UserController'); });
当您使用{$ Quatt}

时,请注意

在我的情况下,问题是我使用了Extra前缀slash喜欢:

Route::get('/performance/{$submit_type}/{$send_selected}/{$date_a}/{$date_b}', 'PerformanceController@calc');

instead:

Route::get('/performance/{submit_type}/{send_selected}/{date_a}/{date_b}', 'PerformanceController@calc');


1
投票
Route::get('/plans', 'PayPalController@getPlansList')->name('paypal.plans');

放在路由中

我发现了可能发生此错误的另一种情况,并且一次没有重写的情况。这是一个非常讨厌的错字:)
我有:

Route::get('plans', 'PayPalController@getPlansList')->name('paypal.plans');

请参阅{?stub},这引起了我的错误,它必须是{stub?}的路线。但是,如果您是Laravel的新手(像我一样),那将很容易错过,并且可能需要一些时间来弄清楚。 :)

1
投票

另一个要检查的东西是您的文档根, Mine是:

www/var
应该是:

www/var/mysite/public

我讨厌网络开发的其他原因
    

1
投票

将其输入root
{$id}
文件

以下代码做三件事:

0
投票
来自URL的Remove

Index.php

来自URL的

将您的问题提交。

注:
{id}

此代码解决您的问题,我的问题未添加

Route::get('replicas/item/{id}/{?stub}', ['uses' => 'ProductReplicasController@productview', 'as' => 'database.replicas.productview']);


0
投票

我也有类似的问题:

RewriteRule ^ index.php [L]

没有工作使用{plan_test}

[L]

我希望这对某人有帮助

我的案子: 我必须使用

index.php

0
投票
RewriteEngine On <IfModule mod_rewrite.c> #Session timeout <IfModule mod_negotiation.c> Options -MultiViews </IfModule> Options +FollowSymlinks RewriteEngine On # Redirect Trailing Slashes... RewriteRule ^(.*)/$ /$1 [L,R=301] RewriteCond %{REQUEST_FILENAME} -d [OR] RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^ ^$1 [N] RewriteCond %{REQUEST_URI} (\.\w+$) [NC] RewriteRule ^(.*)$ public/$1 RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>

中使用了Route::get('/plans/{plan-test}', 'PayPalController@getPlansList')->name('paypal.plans'); 方法

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.