Solar_Uri_Rewrite::setRule()
public
void
Solar_Uri_Rewrite::setRule
( string $key
, mixed $val
)
Sets one rewrite rule; adds it if it is not there, or changes it if it is.
Parameters
(string)
$key
: A shorthand pattern, or a longhand rule name.(mixed)
$val
: A shorthand rewrite string, or a longhand array of information.
Returns
(void)
Description
Sets one rewrite rule; adds it if it is not there, or changes it if it is.
<?php
// shorthand form is 'pattern' and 'rewrite'.
$rewrite->setRule('blog/{:id}/edit', 'blog/edit/$1')
// longhand form is 'rule-name', and an array of information.
// this is what lets you generate named actions using getPath().
$rewrite->setRule('blog-edit', array(
// the pattern to match
'pattern' => 'blog/{:id}/edit',
// rewrite to this
'rewrite' => 'blog/edit/$1',
// custom replacement tokens just for this rule
'replace' => array(
'{:id}' => '(\d*)
),
));