Issue 1 is solved (more or less) with the following solution:
Route::group(array('domain' => 'api.example.com'), function() {
Route::get('/', function() {
return 'API 1';
});
Route::get('test', function() {
return 'API test';
});
Route::any('{all}', function($uri) {
App::abort(404);
})->where('all', '.*');
});
This implements a sort of catch-all route and seems to take priority over the accounts route group.
Issue 2 is now also solved using this solution:
//Check for identity segments
if (Request::segment(1) == 'i' and $identity = (int) Request::segment(2)) {
//Do something with $identity
$prefix = 'i/'.$identity;
}
else {
$prefix = null;
}
//Wrapper for (optional) identity prefix
Route::group(array('prefix' => $prefix), function() {
//Other route groups and routes defined here as usual
});
This way, if there is an identity parameter present, you can filter it out before the routes and set it as a prefix in a wrapper group. If no parameter is given, the prefix is null and is basically ignored.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community