我定义了一个用于对控制器路由进行分组的Route
,并在使用此URL
后:
http://localhost/alachiq/public/admin/profile
它可以显示配置文件视图。 但是如果用户输入:
http://localhost/alachiq/public/admin/profile/
重定向到http://localhost/admin/profile
,我收到此错误:
Not Found
The requested URL /admin/profile was not found on this server.
Apache/2.4.6 (Debian) Server at localhost Port 80
如何在控制器中使用通配符?
我的路线:
Route::group(array('prefix'=> 'admin' ,'before'=>'auth'), function(){
Route::controller('profile', 'ProfileController',array('getIndex'=>'profile.index', 'postUpdate'=>'profile.update'));
});
我想你的 DocumentRoot 应该是/path/to/alachiq/public,但如果你想让它保持原样,你必须修改 htaccess 以考虑子文件夹。
它看起来像这样RewriteRule ^(.*)/$ /alachiq/public/$1 [L,R=301]
如果我明白,你正在寻找这个:
class UserController extends BaseController {
function __construct() {
$this->beforeFilter('auth', array('except' => array('store', 'update')));
$this->beforeFilter('csrf', array('on' => 'post'));
}
}
您可以找到更多代码: Laravel 4 除了控制器构造函数中的过滤器