# Zend_Controller_Router_Route_Hostname

`Zend_Controller_Router_Route_Hostname` is the hostname route of the framework. It works similar to the standard route, but it works on the with the hostname of the called URL instead with the path.

Let's use the example from the standard route and see how it would look like in a hostname based way. Instead of calling the user via a path, we'd want to have a user to be able to call `http://martel.users.example.com` to see the information about the user "martel":

    $hostnameRoute = new Zend_Controller_Router_Route_Hostname(
        ':username.users.example.com',
        array(
            'controller' => 'profile',
            'action'     => 'userinfo'
        )
    );

    $plainPathRoute = new Zend_Controller_Router_Route_Static('');

    $router->addRoute('user', $hostnameRoute->chain($plainPathRoute);

The first parameter in the `Zend_Controller_Router_Route_Hostname` constructor is a route definition that will be matched to a hostname. Route definitions consist of static and dynamic parts separated by the dot ('.') character. Dynamic parts, called variables, are marked by prepending a colon to the variable name: `:username`. Static parts are just simple text: `user`.

Hostname routes can, but never should be used as is. The reason behind that is, that a hostname route alone would match any path. So what you have to do is to chain a path route to the hostname route. This is done like in the example by calling `$hostnameRoute->chain($pathRoute);`. By doing this, `$hostnameRoute` isn't modified, but a new route (`Zend_Controller_Router_Route_Chain`) is returned, which can then be given to the router.