1. <small id='pKiWH'></small><noframes id='pKiWH'>

  2. <legend id='pKiWH'><style id='pKiWH'><dir id='pKiWH'><q id='pKiWH'></q></dir></style></legend>
    • <bdo id='pKiWH'></bdo><ul id='pKiWH'></ul>
    <i id='pKiWH'><tr id='pKiWH'><dt id='pKiWH'><q id='pKiWH'><span id='pKiWH'><b id='pKiWH'><form id='pKiWH'><ins id='pKiWH'></ins><ul id='pKiWH'></ul><sub id='pKiWH'></sub></form><legend id='pKiWH'></legend><bdo id='pKiWH'><pre id='pKiWH'><center id='pKiWH'></center></pre></bdo></b><th id='pKiWH'></th></span></q></dt></tr></i><div id='pKiWH'><tfoot id='pKiWH'></tfoot><dl id='pKiWH'><fieldset id='pKiWH'></fieldset></dl></div>
    <tfoot id='pKiWH'></tfoot>

    1. SymfonyComponentHttpKernelExceptionNotFoundHttpException Lar

      时间:2023-10-31

    2. <small id='QN8LO'></small><noframes id='QN8LO'>

        <tbody id='QN8LO'></tbody>
    3. <tfoot id='QN8LO'></tfoot>

            • <bdo id='QN8LO'></bdo><ul id='QN8LO'></ul>
            • <i id='QN8LO'><tr id='QN8LO'><dt id='QN8LO'><q id='QN8LO'><span id='QN8LO'><b id='QN8LO'><form id='QN8LO'><ins id='QN8LO'></ins><ul id='QN8LO'></ul><sub id='QN8LO'></sub></form><legend id='QN8LO'></legend><bdo id='QN8LO'><pre id='QN8LO'><center id='QN8LO'></center></pre></bdo></b><th id='QN8LO'></th></span></q></dt></tr></i><div id='QN8LO'><tfoot id='QN8LO'></tfoot><dl id='QN8LO'><fieldset id='QN8LO'></fieldset></dl></div>
              <legend id='QN8LO'><style id='QN8LO'><dir id='QN8LO'><q id='QN8LO'></q></dir></style></legend>

              1. 本文介绍了SymfonyComponentHttpKernelExceptionNotFoundHttpException Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试使用 RESTful 控制器.这是我的 Route.php:

                I am trying to use RESTful controller. Here is my Route.php:

                Route::resource('test', 'TestController');
                Route::get('/', function()
                {
                    return View::make('hello');
                });
                

                这是我的 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/ 并显示您已到达"消息.但是当我尝试 localhost/Test/public/test 它给了我SymfonyComponentHttpKernelExceptionNotFoundHttpException"

                My app route is localhost/Test/public/ and it shows "You have arrived" message. But when I tried localhost/Test/public/test It gives me "SymfonyComponentHttpKernelExceptionNotFoundHttpException"

                这是我的日志:

                [2014-05-11 14:29:59] production.ERROR: NotFoundHttpException Route: `http://localhost/Test/public/test` [] []
                [2014-05-11 14:29:59] production.ERROR: exception 'SymfonyComponentHttpKernelExceptionNotFoundHttpException' in C:wampwww	estootstrapcompiled.php:5289
                Stack trace:
                #0 C:wampwww	estootstrapcompiled.php(4663): IlluminateRoutingRouteCollection->match(Object(IlluminateHttpRequest))
                #1 C:wampwww	estootstrapcompiled.php(4651): IlluminateRoutingRouter->findRoute(Object(IlluminateHttpRequest))
                #2 C:wampwww	estootstrapcompiled.php(4643): IlluminateRoutingRouter->dispatchToRoute(Object(IlluminateHttpRequest))
                #3 C:wampwww	estootstrapcompiled.php(698): IlluminateRoutingRouter->dispatch(Object(IlluminateHttpRequest))
                #4 C:wampwww	estootstrapcompiled.php(679): IlluminateFoundationApplication->dispatch(Object(IlluminateHttpRequest))
                #5 C:wampwww	estootstrapcompiled.php(1136): IlluminateFoundationApplication->handle(Object(IlluminateHttpRequest), 1, true)
                #6 C:wampwww	estootstrapcompiled.php(7218): IlluminateHttpFrameGuard->handle(Object(IlluminateHttpRequest), 1, true)
                #7 C:wampwww	estootstrapcompiled.php(7815): IlluminateSessionMiddleware->handle(Object(IlluminateHttpRequest), 1, true)
                #8 C:wampwww	estootstrapcompiled.php(7762): IlluminateCookieQueue->handle(Object(IlluminateHttpRequest), 1, true)
                #9 C:wampwww	estootstrapcompiled.php(10768): IlluminateCookieGuard->handle(Object(IlluminateHttpRequest), 1, true)
                #10 C:wampwww	estootstrapcompiled.php(640): StackStackedHttpKernel->handle(Object(IlluminateHttpRequest))
                #11 C:wampwww	estpublicindex.php(49): IlluminateFoundationApplication->run()
                #12 {main} [] []
                

                我知道这个问题已经被问过很多次了.我经历了许多相关的线程,但无法找出解决方案.

                I know this question has been asked many times. I had gone through many relevant threads but just can not figure out the solution.

                推荐答案

                Laravel 中的 NotFoundHttpException 异常总是意味着它无法为 特定网址.在您的情况下,这可能是您的 Web 服务器配置、虚拟主机(站点)配置或 .htaccess 配置中的问题.

                A NotFoundHttpException exception in Laravel always means that it was not able to find a router for a particular URL. And in your case this is probably a problem in your web server configuration, virtual host (site) configuratio, or .htaccess configuration.

                您的 public/.htaccess 应该如下所示:

                Your public/.htaccess should look like this:

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

                如你所见,第一行IfModule mod_rewrite.c中有一个条件,所以如果你没有安装或启用mode_rewrite,所有的重写规则都会失败,这个

                As you can see there is a condition in the first line IfModule mod_rewrite.c, so if you don`t have mode_rewrite installed or enabled, all rewrite rules will fail and this

                localhost/Test/public/
                

                可以正常工作,但不是这样:

                Will work fine, but not this:

                localhost/Test/public/test
                

                另一方面,这个也应该可以工作,因为这是它的原始形式:

                In other hand, this one should work too, because this is its raw form:

                localhost/Test/public/index.php/test
                

                因为 Laravel 需要重写它才能工作.

                Because Laravel needs it to be rewritten to work.

                请注意,您不应使用/public,您的网址应如下所示:

                And note that you should not be using /public, your URLs should look like this:

                localhost/Test/
                

                这是您的虚拟主机的文档根目录未正确配置或未指向/var/www/Test/public 或您的应用程序所在的任何路径的另一个线索.

                This is another clue that your virtual host's document root is not properly configured or not pointing to /var/www/Test/public, or whatever path your application is in.

                所有这一切都假设您使用的是 Apache 2.

                All this assuming you are using Apache 2.

                这篇关于SymfonyComponentHttpKernelExceptionNotFoundHttpException Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何在 PHP7 下安装 mcrypt?Laravel 需要它 下一篇:无法让 Laravel 4 在本地主机上工作

                相关文章

                  <legend id='tMxYd'><style id='tMxYd'><dir id='tMxYd'><q id='tMxYd'></q></dir></style></legend>
                  1. <tfoot id='tMxYd'></tfoot>
                    <i id='tMxYd'><tr id='tMxYd'><dt id='tMxYd'><q id='tMxYd'><span id='tMxYd'><b id='tMxYd'><form id='tMxYd'><ins id='tMxYd'></ins><ul id='tMxYd'></ul><sub id='tMxYd'></sub></form><legend id='tMxYd'></legend><bdo id='tMxYd'><pre id='tMxYd'><center id='tMxYd'></center></pre></bdo></b><th id='tMxYd'></th></span></q></dt></tr></i><div id='tMxYd'><tfoot id='tMxYd'></tfoot><dl id='tMxYd'><fieldset id='tMxYd'></fieldset></dl></div>

                    <small id='tMxYd'></small><noframes id='tMxYd'>

                    • <bdo id='tMxYd'></bdo><ul id='tMxYd'></ul>