dongxieting9623 2013-10-04 15:57
浏览 80
已采纳

laravel中的子域路由

I have just put a practice laravel app on my development server at app.mydomain.co

I have looked at the docs and I wrapped the routes with the sub domain group like so

 <?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');
    });

The home page works fine but the rest of the routes are 404 not found errors so obviously I am doing something wrong, any ideas?

here is the output for php artisan routes with the domain substituted with 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 

When I look at the apache error log it appears to be looking in the laravel public folder for a file or directory related to the php query so if I am trying to access the questions controller method show with url qapp.app.co/questions/show/14 the error is file does not exist: /var/www/app/public/questions

  • 写回答

2条回答 默认 最新

  • dongliang2005 2013-11-25 19:23
    关注

    I was able to solve my problem by setting AllowOverride to All in the virtual host. Maybe it will work for you too? See http://laracasts.com/forum/351-how-do-you-install-laravel-into-a-subdomain

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作