douzhimao8656 2012-03-06 20:20
浏览 46
已采纳

Zend Framework主机名路由和默认路由

I created a Hostname route like this:

$siteRoute = new Zend_Controller_Router_Route_Hostname(
    ':siteSlug.wordy',
    array(
        'siteSlug' => 'main-site',
        'module' => 'default'
    )
);

and i chain it with default and other rotues like this:

foreach ($router->getRoutes() as $key => $route) {
    $router->addRoute($key, $siteRoute->chain($route));
}

The problems are:

When i got to main-site.wordy there is no problem. but if i go to just wordy i get this error message: No route matched the request

And the other problem is when i go to wordy/admin i get this exception: Invalid controller specified (admin)

How can i solve this?

  • 写回答

1条回答 默认 最新

  • dph19153 2012-04-29 20:46
    关注

    I suggest u to make a htaccess redirect for non www url to 301 redirect on www.wordy in this way u always have :sitename for router hostname !

    RewriteEngine On
    
    RewriteCond %{SERVER_PORT} ^80$
    RewriteCond %{HTTP_HOST} ^wordy$ [NC]
    RewriteRule ^(.*)$ http://www.wordy/$1 [R=301,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services