2012-02-17 110 views
1

我需要一個cakephp路由,如果在不包含文件擴展名的以前路由中不匹配,它將捕獲所有的URL。漁獲以下所有cakephp路由不允許文件擴展名

Router::connect('/*', array('controller' => 'frontend', 'action' => 'display',null)); 

我需要修改,並非所有的URL文件擴展名以上航線

當前路線被抓

回答

0

我在基於CakePHP的1.2添加擴展到動態生成的圖像我的應用程序已經donr如下:

Router::connect('/postImage/*', array('controller' => 'posts','action' => 'postImage', 'url' => array('ext' => 'png'))); 

上面的代碼使得無論是folloing網址是入店: http://myhost.com/posts/postImage/125http://myhost.com/posts/postImage/125.png

我認爲CakePHP 1.3也一樣,我希望它可以幫助你。

0

我不很瞭解你的需求,但你可以做到這一點:

Router::parseExtensions('html'); 
Router::connect('/*/:title', array('controller' => 'frontend', 'action' => 'display',null), 
       array(
     'pass' => array('title') 
    ) 
); 

和鏈接:

$html->link('Title', array('controller' => 'frontend', 'action' => 'display', 'title' => Inflector::slug('text to slug', '-'), 'ext' => 'html')) 

我希望這會幫助你。好運

相關問題