简体   繁体   中英

Is it possible for FuelPHP not to allow the right side of the route?

In config/routes.php

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

I can access site.com/users/account/change_password and site.com/users/account/change_password in the browser.

Is there a way to restrict it to the left side only (ie site.com/users/account/change_password )?

Only by routing it specificly, for example by routing it to the same place as your _404_ controller. Of course you could also do it for the entire controller:

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

That way a direct call on this controller would always go to your 404.

Of course if your routes end in a wild-card route like ':any' => 'catch/everything/$1' you don't need to do this.

To be complete: if you want to allow only HMVC calls, but no URI access, you can also capture it in the controller itself. Either in the before() method (for the entire controller) or in the individual methods:

// throw a 404 if accessed via the URI
if ( ! \Request::active()->is_hmvc())
{
    throw new \HttpNotFoundException();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM