doubing3662
2014-01-06 10:49
浏览 31
已采纳

重定向toUrl不起作用(zf2)

I have a problem with a redirect in Zend Framework 2. when a user enters a url like http//mysite.test/lorem, he will be redirected to http//mysite.test/news/view/lorem-ipsum.

the code:

$redirecttable = $sm->get('Redirect\Model\RedirectTable');
$route = $redirecttable->getRedirectByRoute($this->params()->fromRoute('page'));
if($route) {
    // $route->getToroute() returns "news/view/Lorem-Ipsum"
    return $this->redirect()->toUrl( $route->getToroute() );

}

Am I making a stupid mistake here?

图片转代码服务由CSDN问答提供 功能建议

我在Zend Framework 2中遇到重定向问题。 当用户输入类似http // mysite的网址时 .test / lorem,他将被重定向到http // mysite.test / news / view / lorem-ipsum。</ p>

代码:</ p>

   $ redirecttable = $ sm-&gt; get('Redirect \ Model \ RedirectTable'); 
 $ route = $ redirecttable-&gt; getRedirectByRoute($ this-&gt; params() - &gt; fromRoute('page'  )); 
if($ route){
 // $ route-&gt; getToroute()返回“news / view / Lorem-Ipsum”
返回$ this-&gt; redirect() - &gt; toUrl($ route)  - &gt; getToroute()); 
 
} 
 </ code> </ pre> 
 
 

我在这里犯了一个愚蠢的错误吗?</ p> </ div>

2条回答 默认 最新

相关推荐 更多相似问题