Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3394214
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:08:36+00:00 2026-05-18T04:08:36+00:00

I need to create routing in Zend to simply copy the current live site

  • 0

I need to create routing in Zend to simply copy the current live site url structure which is sadly inconsistent

What i want to do is to route subdomain as follow:

http://www.site.com -> static router

a.site.com & b.site.com -> category controller

c.site.com & d.site.com -> location controller

the rest sub domain -> user controller

could anyone guide me how to solve this, thanks.

UPDATE:

First thanks Fge, vote your answer, it works but i need some more advice:

  1. Since i have many subdomains for each rules is there a better way than add the rules in looping

    foreach($subdomains as $a){
    $tr = new Zend_Controller_Router_Route_Hostname(
    “$a.site.com”,
    array(
    ‘module’ => ‘mod’,
    ‘controller’ => ‘ctrl’,
    ‘param_1’ => $a
    ));
    $router->addRoute($a,$tr);
    }

  2. How to combine it with other routing type to parse the parameters (chained?), something like http://a.site.com/:b/:c, i want t parse it to param_1 (a), param_2 (b), param_2 (c)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:08:37+00:00Added an answer on May 18, 2026 at 4:08 am

    Note: Reverse Matching
    Routes are
    matched in reverse order so make sure
    your most generic routes are defined
    first.

    (Zend_Controller_Router)

    Thus you have to define the route for all other subdomains first, then the specific ones:

    $user = new Zend_Controller_Router_Route_Hostname(
        ':subdomain.site.com',
        array(
            'controller' => 'user'
        )
    );
    $location1 = new Zend_Controller_Router_Route_Hostname(
        'c.site.com',
        array(
            'controller' => 'location'
        )
    );
    $location1 = new Zend_Controller_Router_Route_Hostname(
        'd.site.com',
        array(
            'controller' => 'location'
        )
    );
    // other definitions with known subdomain
    $router->addRoute($user);   // most general one added first
    $router->addRoute($location1);
    $router->addRoute($location2);
    // add all other subdomains
    

    Update for the updated question:
    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 ($request->getParam("subdomain")). If you want the subdomains to be the action of a known controller/model you could replace :subdomain with :action. 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:

    $user = new Zend_Controller_Router_Route_Hostname(
        ':param1.site.com',
        array(
            'controller' => 'user'
        )
    );
    // routes "subdomain".site.com to defaultModul/userController/indexAction with additional parameter param1 => subdomain.
    

    As long as you don’t have any schema in your subdomains it’s very difficult to route them in a general way.

    2) That’s an example where router chains come into play. The outer route would be the hostname route which handles the subdomain and the inner route would handle the :a/:b part. This could look like this for example:

    $user->chain(new Zend_Controller_Router_Route(':a/:b'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a custom routing for this url: /par1/par2/par3/par99/11 The url must
I need to have the URL like photos/13/rate => I have created following routing
Need to create a custom DNS name server using C which will check against
I am looking to create a route which does image resizing, and I want
I have encountered a problem with routing. I need to create this kind of
I need to create a patching routine for my application, it's really small but
I need create custom dialog and put JPanel into it. Is it possible?
i need create an email list sending to many emails. what is best solution
I need create clone repository. but I do not know where can I get
I need create a document word with Java. And I ask, how can I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.