0

config/routes.php

<?php
return array(
    'account/profile/change_password'  => 'users/account/change_password',
);

我可以在浏览器中访问site.com/users/account/change_password和。site.com/users/account/change_password

有没有办法将它限制在左侧(即site.com/users/account/change_password)?

4

2 回答 2

1

只能通过专门路由它,例如通过将它路由到与_404_控制器相同的位置。当然,您也可以为整个控制器执行此操作:

'users/account(/:any)' => 'my/404/route',

这样,对该控制器的直接调用将始终转到您的 404。

当然,如果您的路线以通配符路线结束,':any' => 'catch/everything/$1'您不需要这样做。

于 2012-04-01T17:37:42.970 回答
0

要完整:如果您只想允许 HMVC 调用,但不允许 URI 访问,您也可以在控制器本身中捕获它。在 before() 方法(对于整个控制器)或单个方法中:

// throw a 404 if accessed via the URI
if ( ! \Request::active()->is_hmvc())
{
    throw new \HttpNotFoundException();
}
于 2013-06-11T10:34:01.997 回答