在你的config/routes.php文件
Router::connect('/questions/*', array('controller' => 'questions', 'action' => 'view'));
在控制器/ QuestionsController.php
视图操作GET问题id作为
public function view() {
$question_id = isset($this->request->params['pass'][0]) ? $this->request->params['pass'][0] : "";
$question = isset($this->request->params['pass'][1]) ? $this->request->params['pass'][1] : "";
if(empty($question_id)) {
throw new NotFoundException('Could not find that question');
}
// if $question is empty then get slug from database and redirect to /question_id/question
// Get question details and set
}
这是什么都与“_controller aliases_做“?大胆的部分是重头戏的问题标题。究竟是什么实际问题?你读过[**文档**](http://book.cakephp.org/2.0/en/development/routing.html#passing-parameters-to-action)吗? ps,请始终提及您的确切CakePHP版本并相应地标记您的问题。 – ndm 2014-10-20 13:18:33
请注意,SO实际上忽略了问题标题,并且可以在其中放置[任何你喜欢的](http://stackoverflow.com/questions/26466567/this-is-a-silly-url),但是如果你得到它错误(这是问题ID是重要的) – DavidG 2014-10-20 13:20:30
实际的问题是,我不知道如何把它放在那里,URL中的问题标题。 – user1148875 2014-10-20 13:23:48