CakePhp Routing Problem
Question
When an action handles a request to a url like: 'http://localhost/sandbox/destination/one%23two', should I expect $this->params['pass'][0] to be 'one#two'? In the event, it is just 'one'. (Cakephp 1.2)Compare: http://www.google.com/#sclient=psy&num=10&hl=en&q=one%23two
Answer
The difference is that the google url has the hash in the query string (though they do now put that weird one where I'd expect a ?). I guess that's the difference. I wanted to allow it as a parameter through the url path. But it appears that's not possible, at least without a bit of cumbersome manual encoding and decoding.Sample Code
simple controller (sandbox_controller.php) action function test()
{
$this->redirect(sprintf('/sandbox/destination/%s',
urlencode('one#two')));
}
function destination()
{
pr($this->params);
}
{
$this->redirect(sprintf('/sandbox/destination/%s',
urlencode('one#two')));
}
function destination()
{
pr($this->params);
}
Browse to http://localhost/sandbox/test
End up here: http://localhost/sandbox/destination/one%23two
Output
[There are no comments on this page]