Skip to content

Instantly share code, notes, and snippets.

@tonyhb
Created July 24, 2010 21:21
Show Gist options
  • Save tonyhb/488971 to your computer and use it in GitHub Desktop.
Save tonyhb/488971 to your computer and use it in GitHub Desktop.
// API
Route::set('api', '(<action>(/<subaction>))')
->defaults(array(
'subdomain' => 'api', // api.domain.com
'controller' => 'api',
'action' => 'index',
));
// Load the website
Route::set('welcome', '(<action>(/<subaction>))')
->defaults(array(
'subdomain' => 'www|^$', // www.domain.com or domain.com
'controller' => 'welcome',
'action' => 'index',
));
// Load a members account based on subdomain
Route::set('members', '(<action>(/<id>))')
->defaults(array(
'subdomain' => '^.+(?<!www|api)$', // anything but www.domain.com, api.domain.com or domain.com (reserved names)
'controller' => 'members',
'action' => 'index',
));
// Catch all
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'subdomain' => false, // no subdomain at all
'controller' => 'welcome',
'action' => 'index',
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment