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

报告相同问题?

悬赏问题

  • ¥15 调用函数时,无关变量的改变引起函数值的改变
  • ¥15 xy坐标转化为经纬度坐标
  • ¥15 一般三角模糊数的上界值和下届值取中值的多少比较合理?
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥20 Hbase启动失败,无法启动HMaster
  • ¥15 sqpingboot在父模块已经引入了mybatisplus 在子组件不写版本号还是报错
  • ¥20 Lumerical FDTD solutions 中模型的相对阻抗,有效介电常数和有效磁导率的实部和虚部的数据如何获得?
  • ¥100 sql reporting service 远程smtp服务器配置支持
  • ¥15 ppyoloe_r带角度目标检测,loss_cls没法收敛
  • ¥15 淘宝交易指数如何解读,其关联的数据指标是什么