mod rewrite - CakePHP use Regex variable capture in routes? -
in cakephp app have static pages set this:
router::connect( '/terms', array('controller' => 'pages', 'action' => 'display', 'terms') );
this rewrite /terms
/pages/display/terms
make prettier shorter urls.
now if wanted static pages, quite redundant:
router::connect( '/terms', array('controller' => 'pages', 'action' => 'display', 'terms') ); router::connect( '/privacy', array('controller' => 'pages', 'action' => 'display', 'privacy') ); router::connect( '/about', array('controller' => 'pages', 'action' => 'display', 'about') );
with regular mod_rewrite can this:
/(terms|privacy|about) /pages/display/$1
so naturally attempted this:
router::connect( '/(terms|privacy|about)', array('controller' => 'pages', 'action' => 'display', '$1') );
it not work. there support this, if how do it?
just off top of head, may solve issue. perform regex match on portion need this:
router::connect( '/:page', array( 'controller' => 'pages', 'action' => 'display', ), array( 'page' => '(terms|privacy|about)', 'pass' => array('page') ) );
notice how page
placeholder in url gets extrapolated on in third parameter, array. in there must match provided regular expression. of note says pass page
placeholder action
method. way knows page render.
Comments
Post a Comment