Query regarding subdomain redirection in Zend Framework

好久不见. 提交于 2019-12-23 01:57:08

问题


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:


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.



来源:https://stackoverflow.com/questions/6011514/query-regarding-subdomain-redirection-in-zend-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!