php - Laravel redirect issue -


i using laravel 4. when "logged_in_id" found in session want continue parse through bellow written routes.

route::get('/{anything}', function($anything) {     if(!session::has('logged_in_id')) {         return view::make('user.login');     } else {         //continue check route::get written bellow routing     } })->where('anything', '[a-za-z0-9\/?=]+');  

if write redirect::to('/'.$anything) enters same route , keeps on redirecting in loop. there way solve problem?

i create filter , apply routes need it.

remember put first routes more restrictive , last more generic ones.

see example:

route::filter('logged_in', function() {     if(!session::has('logged_in_id')) {         return view::make('user.login');     } });  route::get('testing',  array(     'before' => 'logged_in',     function()     {         return view::make('user.testing');     } ));  route::get('/{anything}', array(     'before' => 'logged_in',      function($anything)     {         return view::make('user.anything');     }  ))->where('anything', '[a-za-z0-9\/?=]+'); 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -