我有一个处理URL的动作details
:
something/details/Location/6
这个可以很好的工作。但是我想把额外的细节放在最后,基本上是为了搜索引擎优化。
我的routes.yml中有:
---
Name: mysiteroutes
---
Director:
rules:
'something//$Action/$Location/$OtherID': 'SomeController'
在我的控制器中:
private static $url_handlers = array(
'something//$Action/$Location/$OtherID' => 'handleAction'
);
如果我转到上面的renderWith()
,它可以工作,但是如果我转到something/details/Location/6/test
,它会返回404,即使操作仍在加载并通过URL返回自身
我怎么才能让它工作呢?我也不关心ID之后的细节。
发布于 2018-08-15 09:11:48
我想你终于可以添加更多的参数了
---
Name: mysiteroutes
---
Director:
rules:
'something': 'SomeController'
和你的控制器
private static $allowed_actions = array('details');
private static $url_handlers = array(
'details/$Location/$OtherID/$otherParam' => 'details'
);
public function details() {
$this->getRequest()->param('otherParam');
/* more processing goes here */
}
更多信息https://docs.silverstripe.org/en/3/developer_guides/controllers/routing/
https://stackoverflow.com/questions/51851481
复制相似问题