• <small id='nJPt6'></small><noframes id='nJPt6'>

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

    1. <tfoot id='nJPt6'></tfoot>
      • <bdo id='nJPt6'></bdo><ul id='nJPt6'></ul>

        <legend id='nJPt6'><style id='nJPt6'><dir id='nJPt6'><q id='nJPt6'></q></dir></style></legend>

        我的路线返回 404,我该如何修复它们?

        时间:2023-10-31
        • <tfoot id='qFYNK'></tfoot>

              <tbody id='qFYNK'></tbody>

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

              <legend id='qFYNK'><style id='qFYNK'><dir id='qFYNK'><q id='qFYNK'></q></dir></style></legend>

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

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

                  本文介绍了我的路线返回 404,我该如何修复它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我刚开始学习 Laravel 框架,但遇到了路由问题.

                  I've just started learning the Laravel framework and I'm having an issue with routing.

                  唯一有效的路由是附加到 Laravel 开箱即用的默认主路由.

                  The only route that's working is the default home route that's attached to Laravel out of the box.

                  我在 Windows 上使用 WAMP,它使用 PHP 5.4.3 和 Apache 2.2.22,我还启用了 mod_rewrite,并从 application.php 配置文件中删除了index.php"以留下空字符串.

                  I'm using WAMP on Windows and it uses PHP 5.4.3, and Apache 2.2.22, and I also have mod_rewrite enabled, and have removed the 'index.php' from the application.php config file to leave an empty string.

                  我创建了一个名为 User 的新控制器:

                  I've created a new controller called User:

                  class User_Controller extends Base_Controller {
                  
                      public $restful = true;
                  
                      public function get_index() 
                      {
                          return View::make('user.index');
                      }
                  }
                  

                  我在 application/views/user/中创建了一个名为 index.php 的视图文件,其中包含一些基本的 HTML 代码,并在 routes.php 中添加了以下内容:

                  I've created a view file in application/views/user/ called index.php with some basic HTML code, and in routes.php I've added the following:

                  Route::get('/', function () {
                      return View::make('home.index');
                  });
                  
                  Route::get('user', function () {
                      return View::make('user.index');
                  });
                  

                  在我的网络浏览器中访问根目录 (http://localhost/mysite/public) 时,第一条路线可以正常工作,但是当我尝试使用 http 转到第二条路线时://localhost/mysite/public/user 我收到 404 Not Found 错误.为什么会发生这种情况?

                  The first route works fine when visiting the root (http://localhost/mysite/public) in my web browser, but when I try to go to my second route with http://localhost/mysite/public/user I get a 404 Not Found error. Why would this be happening?

                  推荐答案

                  您是否尝试将其添加到您的路由文件中,而不是 Route::get('user', "user@index")?

                  Have you tried adding this to your routes file instead Route::get('user', "user@index")?

                  @ 之前的一段文本,在本例中为 user,将页面定向到用户控制器,@<之后的一段文本/code>,index,会将脚本定向到 user 函数 public function get_index().

                  The piece of text before the @, user in this case, will direct the page to the user controller and the piece of text after the @, index, will direct the script to the user function public function get_index().

                  我看到您正在使用 $restful,在这种情况下,您可以将 Route 设置为 Route::any('user', 'user@索引').这将同时处理 POSTGET,而不是分别写出它们.

                  I see you're using $restful, in which case you could set your Route to Route::any('user', 'user@index'). This will handle both POST and GET, instead of writing them both out separately.

                  这篇关于我的路线返回 404,我该如何修复它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                    1. <tfoot id='LRCVd'></tfoot>
                        <tbody id='LRCVd'></tbody>

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

                            <legend id='LRCVd'><style id='LRCVd'><dir id='LRCVd'><q id='LRCVd'></q></dir></style></legend>