Query regarding subdomain redirection in Zend Fram

2019-05-30 13:47发布

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!

1条回答
一纸荒年 Trace。
2楼-- · 2019-05-30 13:50

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.

查看更多
登录 后发表回答