DISCLAIMER:
I would highly suggest against making http://somesite.com/page and http://somesite.com/page/ being different pages- it will become confusing for you and for your visitors.
If you're truly dedicated to this plan
you can create your own router you can that handles this by creating your own match() and assemble() functions that don't trim()
the path based on trailing slashes.
class My_Route_Redirector implements Zend_Controller_Router_Route_Interface {
protected $_defaults;
public static function getInstance(Zend_Config $config) {
$defs = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
return new self($defs);
}
public function __construct($defaults=array()) {
$this->_defaults = $defaults;
}
public function match($path, $partial = false) {
if (preg_match("#^/?([a-z0-9]+)$#i", $path, $matches)) {
// this is just an idea but what about if you had this test
// $matches[1] versus the database of redirectors? and only return true
// when it found a valid redirector?
return array('redirectid' => $matches[1]) + $this->_defaults;
} else {
return false;
}
}
public function assemble($data = array(), $reset = false, $encode = false, $partial = false)
{
if (!isset($data['redirectid'])) return '';
return $data['redirectid'];
}
}
That was air coded so it may have a bug or two to work out - it should work like this:
$route = new My_Route_Redirector(
array(
'controller' => 'redirect',
'action' => 'redirect'
)
);