+ Reply to Thread
Results 1 to 1 of 1

Thread: router question - how to hide default module, controller and action in url?

  1. #1
    zfuser is offline Junior Member
    Join Date
    Apr 2007
    Posts
    3

    Default router question - how to hide default module, controller and action in url?

    I created router
    [PHP]$router = $frontController->getRouter();
    $router->addRoute(
    'url',
    new Zend_Controller_Router_Route(':lang/:module/:category/:controller/:action/:test',
    array('module'=>'default', 'controller' => 'index', 'action' => 'index', 'lang' => 'en', 'category'=> 'categ1'))
    );[/PHP]

    when url is http://domain/en/default/pc/index/index/something/ everything works fine. $this->getRequest(); output in Controller is
    [PHP]["_paramsrotected"] => array(6) {
    ["lang"] => string(2) "en"
    ["module"] => string(7) "default"
    ["category"] => string(2) "pc"
    ["controller"] => string(5) "index"
    ["action"] => string(5) "index"
    ["test"] => string(9) "something"
    }
    [/PHP]
    Problem occurs when I change url, for example remove default index controller and action http://domain/en/default/pc/something/

    error is:
    Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (en)' in C:\wamp\www\ZendFramework-1.0.3\library\Zend\Controller\Dispatcher\Standard. php:198 ...

    What should I change in router definition if I want that results of these urls:
    http://domain/en/default/pc/index/index/something/
    http://domain/en/pc/index/index/something/
    http://domain/en/pc/index/something/
    http://domain/en/pc/something/
    http://domain/pc/something/

    be the same?:
    [PHP]["_paramsrotected"] => array(6) {
    ["lang"] => string(2) "en"
    ["module"] => string(7) "default"
    ["category"] => string(2) "pc"
    ["controller"] => string(5) "index"
    ["action"] => string(5) "index"
    ["test"] => string(9) "something"
    }[/PHP]
    Last edited by zfuser; 01-18-2008 at 09:58 AM.

+ Reply to Thread

Similar Threads

  1. modular setup has /public looking for public controller in default module
    By brian.fegan in forum Installation & Configuration
    Replies: 3
    Last Post: 07-15-2010, 01:43 PM
  2. Language / Module / Controller / Action Help
    By kangarooit in forum Model-View-Controller (MVC)
    Replies: 3
    Last Post: 09-22-2009, 11:28 PM
  3. Zend Router Controller Action Helper Url - URL Rewriting
    By DarKA in forum Model-View-Controller (MVC)
    Replies: 0
    Last Post: 10-02-2008, 12:08 PM
  4. Question about default router
    By horseatingweeds in forum General Q&A on Zend Framework
    Replies: 0
    Last Post: 07-28-2008, 07:04 PM
  5. Module/Controller/Action Routing Problem
    By nite-rain in forum Model-View-Controller (MVC)
    Replies: 1
    Last Post: 07-04-2008, 11:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts