1

I was looking for an approach using Zend Framework - similar to sites like bit.ly and tinyurl - where I can take a request to a subdomain and store the subdomain in a variable.

For instance, a request to localhost/abcdef will return $s = abcdef. I'm not sure how to accomplish this in ZF, where a request to localhost/abcdef will return the init() of the abcdef controller.

Thanks for all the help!

Matt
  • 69
  • 1
  • 6

1 Answers1

2

Just use a regex route.

$routeitem = new Zend_Controller_Router_Route_Regex('(.*)',
                    array(1 => '', 'controller' => 'redir', 'action' => 'view'),
                    array(1 => 'hash'),
                    '%s'
    );

You can then get your "hash" redirection from the _getParam method.

Jean-Christophe Meillaud
  • 1,961
  • 1
  • 21
  • 27
  • First of all, thanks ... you have been tremendously helpful! The problem is that I seem to be encountering circular redirects. Is there anyway to have Zend_Controller_Router redirect to the default controller/action _unless_ controller doesn't exist? In other words, instead of **returning page not found** to a request to localhost/abcdef, store abcdef in a variable, while a request to localhost/controller will call init(). – Matt May 16 '11 at 06:42