0

For dynamic image resourcing I want to fool the browser the url is image instead of a 'plain'/dynamic url. Therefor I'm using Zend_Controller_Router_Route. I'm just not sure how to fill my reverse string. I have the following route build:

'refactor-index-index-public' =>
  array(
    'type' => 'Zend_Controller_Router_Route_Regex',
    'route' => '\/public\/upload\/img\/(\w+)\/(\d+)x(\d+)\/(\d+)\/(\d+)\/(\d+)\/img.(\w+)',
    //'route' => "/public/upload/img/testimage/500x500/0/0/0/img.webp",
    'defaults' =>
    array(
      'module' => 'refactor',
      'controller' => 'index',
      'action' => 'index',
    ),
    'map' =>
    array(
      'id'          => 1,
      'width'       => 2,
      'height'      => 3,
      'keepSmaller' => 4,
      'keepRatio'   => 5,
      'crop'        => 6,
      'extension'   => 7,
    ),
    'reverse'       => '/public/upload/img/%s/%dx%d/%d/%d/%d/img.%s',
  )

My controller with a Zend_Debug::dump('rerouted'); exit; is not triggering.

IMarks
  • 187
  • 11
  • Don't escape the slashes in the regex. I'm not sure why you have "public" in your URLs. Other than that, what isn't working? What URL isn't matching this route? – Tim Fountain Aug 23 '17 at 18:27
  • The url in commented route just returns the image. While the first statement of my index action of refactor_indexController is Zend_Debug::dump('rerouted'); exit;. The file itself exactly exist and that is what is now returned. But I want the action to be reached so it can decide what to return (so I can make it that when a image that doesn't exist by the provided parameters, the image can be created (based on the original by the provided ID. – IMarks Aug 23 '17 at 18:34
  • Public is used as that's the only folder that is accessible. All the others are locked down by .htaccess file. – IMarks Aug 23 '17 at 18:35
  • The default rewrite rules will return static files if they exist (instead of routing the request through ZF), so you might need to change that if you don't want that to happen. If "public" is in your URLs your vhost is not setup correctly (or you are using a host where you can't change the vhost). – Tim Fountain Aug 23 '17 at 18:43
  • Any example on how to overwrite the default rewrite rules in regard to letting the ZF goes over files. For the public matter I not sure what's the issue on it. I have it locked down by the htaccess files in all other folders (including root dir). So only routes are the on by ZF or the public folder. – IMarks Aug 23 '17 at 18:53

0 Answers0