How to allow all except part 1 and part 2 ?

Posted by Stackfan on Stack Overflow See other posts from Stack Overflow or by Stackfan
Published on 2011-01-04T20:53:08Z Indexed on 2011/01/08 9:54 UTC
Read the original article Hit count: 211

Filed under:
|
|
|

This allows me to get easyly dynamic input variables instead of putting a static prefix like /en/etcetcetc, but the problem is all controllers are blocked. Everything goes to index/index.

Question: How can i tell this rule allow evertying as it is now, but do not track if it contains http://site.com/donotcatch/me and http://site.com/iamnotbelongstodynamic1/blabla

  protected  function _initRoutes()
  { 
     ...
      $dynamic1 = new Zend_Controller_Router_Route(
            '/:variable0/:variable1',
            array(
                'controller' => 'index',
                'action'     => 'index'),
                array(
                      'variable0' => '^[a-zA-Z0-9_]*$',
                      'variable1' => '^[a-zA-Z0-9_]*$',
                    )
            );

Follow up:

Normally, i always belive yes we can, so, we can do that like this where dynamic1 does not the inter-fare with my other static controllers:

  // http://site/yeswecan/blabla
  // variable0 = yeswecan
  // variable1 = blabla
  $dynamic1 = new Zend_Controller_Router_Route(
        '/:variable0/:variable1',
        array(
            'controller' => 'index',
            'action'     => 'index'),
            array(
                  'variable0' => '^[a-zA-Z]*$',
                  'variable1' => '^[a-z0-9_]*$',
                )
        );


  // http://site/ajax/whatever...
  // solves it
  $dynamic2 = new Zend_Controller_Router_Route(
        '/ajax/:variable0',
        array(
            'controller' => 'ajax',
            'action'     => ''
            ),
            array(
                  'variable0' => '^[a-zA-Z0-9_]*$',
                )
        );

  // http://site/order/whatever...
  // solves it
  $dynamic3 = new Zend_Controller_Router_Route(
        '/order/:variable0',
        array(
            'controller' => 'order',
            'action'     => ''),
            array(
                  'variable0' => '^[a-zA-Z0-9_]*$',
                )
        ); 

Note:

  • Still the controllers are getting failed for example http://site/ajax/whatever always goes to /ajax/index where i wanted to send it as /ajax/user-inserted-value

How can i fix the $dynamic2 and $dynamic3 by keeping $dynamic1 ??

© Stack Overflow or respective owner

Related posts about php

Related posts about zend-framework