dou4381
2014-02-11 07:35
浏览 36
已采纳

用于控制器路由的Laravel通配符?

I defined a Route for grouping controller routes and after using this URL :

http://localhost/alachiq/public/admin/profile

it can show profile view. but if user entered:

http://localhost/alachiq/public/admin/profile/

that redirects to http://localhost/admin/profile and I get this error:

Not Found

The requested URL /admin/profile was not found on this server.
Apache/2.4.6 (Debian) Server at localhost Port 80

how to use a wildcard in controller?

my Route:

Route::group(array('prefix'=> 'admin' ,'before'=>'auth'), function(){
    Route::controller('profile', 'ProfileController',array('getIndex'=>'profile.index', 'postUpdate'=>'profile.update'));

});
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanmeng9336 2014-02-11 07:50
    已采纳

    I guess your DocumentRoot should be /path/to/alachiq/public, but if you want it to stay how it is here, you have to modify the htaccess to take the subfolders into account.
    It would look like this RewriteRule ^(.*)/$ /alachiq/public/$1 [L,R=301]

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • dongqing6755 2014-02-11 07:58

    If i understand, you are searching for this:

    class UserController extends BaseController {
    
        function __construct() {
            $this->beforeFilter('auth', array('except' => array('store', 'update')));
            $this->beforeFilter('csrf', array('on' => 'post'));
        }
    }
    

    You can found more code: Laravel 4 except filter in controller constructor

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题