Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p><strong>Note: Reverse Matching</strong><br> Routes are matched in reverse order so make sure your most generic routes are defined first.</p> </blockquote> <p><a href="http://framework.zend.com/manual/en/zend.controller.router.html" rel="nofollow">(Zend_Controller_Router)</a></p> <p>Thus you have to define the route for all other subdomains first, then the specific ones:</p> <pre><code>$user = new Zend_Controller_Router_Route_Hostname( ':subdomain.site.com', array( 'controller' =&gt; 'user' ) ); $location1 = new Zend_Controller_Router_Route_Hostname( 'c.site.com', array( 'controller' =&gt; 'location' ) ); $location1 = new Zend_Controller_Router_Route_Hostname( 'd.site.com', array( 'controller' =&gt; 'location' ) ); // other definitions with known subdomain $router-&gt;addRoute($user); // most general one added first $router-&gt;addRoute($location1); $router-&gt;addRoute($location2); // add all other subdomains </code></pre> <p><strong>Update for the updated question:</strong><br> 1) This really depends on how different the parameters are you want to route a subdomain to. In your example you routed them all to the same model and controller and added the actual subdomain as a parameter. This can be done easily with the user-route i posted above. There the subdomain is set as parameter subdomain (<code>$request-&gt;getParam("subdomain")</code>). If you want the subdomains to be the action of a known controller/model you could replace <code>:subdomain</code> with <code>:action</code>. But as soon as you have other controllers/models for each subdomain, I'm affraid you have to loop over them (or use a config file). For the example you provided in the question, the route simply could look like this:</p> <pre><code>$user = new Zend_Controller_Router_Route_Hostname( ':param1.site.com', array( 'controller' =&gt; 'user' ) ); // routes "subdomain".site.com to defaultModul/userController/indexAction with additional parameter param1 =&gt; subdomain. </code></pre> <p>As long as you don't have any schema in your subdomains it's very difficult to route them in a general way.</p> <p>2) That's an example where <a href="http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.chain" rel="nofollow">router chains</a> come into play. The outer route would be the hostname route which handles the subdomain and the inner route would handle the <code>:a/:b</code> part. This could look like this for example:</p> <pre><code>$user-&gt;chain(new Zend_Controller_Router_Route(':a/:b')); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload