laravel中的子域路由

时间:2013-10-04 15:57:54

标签: php laravel laravel-4

我刚刚在app.mydomain.co

的开发服务器上安装了练习laravel应用程序

我查看了文档,并将路径与子域组包装起来,如此

 <?php

    /*
    |--------------------------------------------------------------------------
    | Application Routes
    |--------------------------------------------------------------------------
    |
    | Here is where you can register all of the routes for an application.
    | It's a breeze. Simply tell Laravel the URIs it should respond to
    | and give it the Closure to execute when that URI is requested.
    |
    */
    Route::group(array('domain' => 'app.mydomain.co'), function()
    {
    Route::get('/', array('as'=>'home', 'uses'=>'QuestionController@getIndex'));
    //Route::get('create', array('as'=>'create', 'uses'=>'UserController@getCreate'));
    //Route::get('login', array('as'=>'login', 'uses'=>'UserController@getLogin'));

    /*
        Define RESTful Controllers
    */
        Route::controller('user', 'UserController');
        Route::controller('questions', 'QuestionController');
    });

主页工作正常,但其余的路线是404找不到错误,所以显然我做错了什么,有什么想法吗?

这是php artisan路线的输出,其中域名由app

替换
+--------------+--------------------------------------------------------+------+-------------------------------------+----------------+---------------+
| Domain       | URI                                                    | Name | Action                              | Before Filters | After Filters |
+--------------+--------------------------------------------------------+------+-------------------------------------+----------------+---------------+
| qapp.app.co | GET /user/index/{v1}/{v2}/{v3}/{v4}/{v5}               |      | UserController@getIndex             |                |               |
| qapp.app.co | GET /user                                              |      | UserController@getIndex             |                |               |
| qapp.app.co | GET /user/create/{v1}/{v2}/{v3}/{v4}/{v5}              |      | UserController@getCreate            |                |               |
| qapp.app.co | POST /user/store/{v1}/{v2}/{v3}/{v4}/{v5}              |      | UserController@postStore            |                |               |
| qapp.app.co | GET /user/login/{v1}/{v2}/{v3}/{v4}/{v5}               |      | UserController@getLogin             |                |               |
| qapp.app.co | POST /user/login/{v1}/{v2}/{v3}/{v4}/{v5}              |      | UserController@postLogin            |                |               |
| qapp.app.co | GET /user/logout/{v1}/{v2}/{v3}/{v4}/{v5}              |      | UserController@getLogout            |                |               |
| qapp.app.co | GET /user/{_missing}                                   |      | UserController@missingMethod        |                |               |
| qapp.app.co | GET /questions/index/{v1}/{v2}/{v3}/{v4}/{v5}          |      | QuestionController@getIndex         |                |               |
| qapp.app.co | GET /questions                                         |      | QuestionController@getIndex         |                |               |
| qapp.app.co | POST /questions/store/{v1}/{v2}/{v3}/{v4}/{v5}         |      | QuestionController@postStore        |                |               |
| qapp.app.co | GET /questions/show/{v1}/{v2}/{v3}/{v4}/{v5}           |      | QuestionController@getShow          |                |               |
| qapp.app.co | GET /questions/edit/{v1}/{v2}/{v3}/{v4}/{v5}           |      | QuestionController@getEdit          |                |               |
| qapp.app.co | PUT /questions/update/{v1}/{v2}/{v3}/{v4}/{v5}         |      | QuestionController@putUpdate        |                |               |
| qapp.app.co | GET /questions/your-questions/{v1}/{v2}/{v3}/{v4}/{v5} |      | QuestionController@getYourQuestions |                |               |
| qapp.app.co | GET /questions/{_missing}                              |      | QuestionController@missingMethod    |                |               |
|              | GET /                                                  | home | QuestionController@getIndex 

当我查看apache错误日志时,它似乎在laravel公共文件夹中查找与php查询相关的文件或目录,因此如果我尝试访问问题控制器方法show with url qapp.app.co / questions / show / 14错误是文件不存在:/ var / www / app / public / questions

2 个答案:

答案 0 :(得分:0)

  

主页工作正常,但其余路线未找到错误,所以显然我做错了

这可能会给你一个暗示你的配置实际上有什么问题的提示。该路线将从上到下排列优先顺序,因此从技术上讲,您应该在底部定义“/”路线(而不是顶部。

答案 1 :(得分:0)

我能够通过在虚拟主机中将AllowOverride设置为All来解决我的问题。也许它对你也有用?见http://laracasts.com/forum/351-how-do-you-install-laravel-into-a-subdomain