Php laravel中的子域路由
我刚刚在app.mydomain.co的开发服务器上安装了一个practice laravel应用程序 我已经看过了文档,我用子域组包装了路由,就像这样Php laravel中的子域路由,php,laravel,laravel-4,Php,Laravel,Laravel 4,我刚刚在app.mydomain.co的开发服务器上安装了一个practice laravel应用程序 我已经看过了文档,我用子域组包装了路由,就像这样 <?php /* |-------------------------------------------------------------------------- | Application Routes |---------------------------------------------
<?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');
});
当我查看apache错误日志时,它似乎在laravel公用文件夹中查找与php查询相关的文件或目录,因此,如果我试图访问带有url qapp.app.co/questions/show/14的questions controller方法show,则错误是文件不存在:/var/www/app/public/questions
主页工作正常,但其余的路线没有发现错误,所以很明显我做错了什么
这已经给了你一个提示,你的配置到底出了什么问题。路由将从上到下排列优先级,因此技术上您应该在底部定义“/”路由(而不是顶部。我可以通过在虚拟主机中将AllowOverride设置为All来解决我的问题。也许它也适用于您?请参见您没有在路由中定义任何参数来存储子域,因此我根本看不到使用子域路由的意义。子域路由旨在用于子域的某些方面一个.Example:Route::group(array('domain'=>'{language}.mydomain.co'),function(){//可能是在这里更改全局语言……//App::setLocale($language);//……或者只需将其传递给routes/controllers Route::get('user/{id}',function($language,$id){/*…*/});});我只希望能够从app.mydomain正常使用该应用程序。co@Ir1sh你解决了这个问题吗?@aaronjbaptiste no还没有发现问题。谢谢,但是移动回家路线的定义没有任何影响,我仍然收到一个404错误
+--------------+--------------------------------------------------------+------+-------------------------------------+----------------+---------------+
| 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