简体   繁体   中英

PHP Frameworks - One-way routing

In CodeIgniter's routes file, it is possible to map URLs to controller methods like this:

$route['url/segment/(:num)'] = 'controller/methodasdf/$1';

It works great, but what I'd like to do is stop the user calling the end route directly ( methodasdf ). I've tried setting the methods to private and prefixing them with an underscore, but that just results in a 404 error.

在控制器中,您可以检查$ this-> uri-> segment(1)=='your_nice_segment',如果不是,则可以向他显示错误

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