帮助创建 Zend Framework 重定向

发布于 2024-11-07 14:48:21 字数 403 浏览 4 评论 0原文

我正在尝试创建一个 mod 重写表达式以从 localhost/1234 重定向到 localhost/controller/action?param=1234。

我的 bootstrap.php 中有以下内容,它以 localhost/number 的形式重定向所有请求

$routePublic = new Zend_Controller_Router_Route_Regex('^[\d]+(\.[\d]+){0,1}$', array( 1 => '' ,'controller' => 'content', 'action' => 'public'));

,但是,我需要将参数传递给我的 publicAction。

感谢您的帮助。像我这样的新手比你想象的更欣赏它!

I'm trying to create a mod rewrite expression to redirect from localhost/1234 to localhost/controller/action?param=1234.

I have the following in my bootstrap.php, which redirects all requests in the form localhost/number

$routePublic = new Zend_Controller_Router_Route_Regex('^[\d]+(\.[\d]+){0,1}

However, I need to pass a param to my publicAction.

Thanks for the help. Newbies like me appreciate it more than you could ever believe!

, array( 1 => '' ,'controller' => 'content', 'action' => 'public'));

However, I need to pass a param to my publicAction.

Thanks for the help. Newbies like me appreciate it more than you could ever believe!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撞了怀 2024-11-14 14:48:21

试试这个:

$frontController = Zend_Controller_Front::getInstance();
$frontController->getRouter()->addRoute('name_of_route', 
            new Zend_Controller_Router_Route('/url_of_route/*', 
            array('controller'=>'controller_you_want_to_call','action'=>'action_you_want_to_call')));

请注意,“url_of_route”后面的“*”就像一个通配符,意味着它后面可以有任何内容

此外还有一个指向 好文章

try this:

$frontController = Zend_Controller_Front::getInstance();
$frontController->getRouter()->addRoute('name_of_route', 
            new Zend_Controller_Router_Route('/url_of_route/*', 
            array('controller'=>'controller_you_want_to_call','action'=>'action_you_want_to_call')));

note that the "*" after "url_of_route" is like a wildcard meaning anything can come after it

Also heres a link to a good article

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文