Manual
Sub-Domain Support
Routes comes with sub-domain support to make it easy to handle sub-domains in
an integrated fashion. When sub-domain support is turned on, Routes will
always have a subDomain
argument present with the sub-domain if present, or
None.
To avoid matching common aliases to your main domain like www, the sub-domain support can be set to ignore some sub-domains.
Example:
$m = new Horde_Routes_Mapper(); // Turn on sub-domain support $m->subDomains = true; // Ignore the www sub-domain $m->subDomainsIgnore = array('www');
Generating URLs with sub-domains
When sub-domain support is on, the urlFor()
function will accept a subDomain
keyword argument. Routes will then ensure that the generated URL has the
sub-domain indicated. This feature works with Route memory to ensure that the
sub-domain is only added when necessary.
Some examples:
// Assuming that the current URL from the request is http://george.example.com/users/edit // Also assuming that you're using the map options above with the default routing of // ':controller/:action/:id' $utils->urlFor(array('action'=>'update', 'subDomain'=>'fred') # -> http://fred.example.com/users/update $utils->urlFor(array('controller'=>'/content', 'action'=>'view', 'subDomain'=>'www')); # will become -> http://example.com/content/view $utils->urlFor(array('action'=>'new', 'subDomain'=>null) # -> http://example.com/users/new