Restrict access to controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Restrict access to controller (/showthread.php?tid=66703) |
Restrict access to controller - JackWhite - 11-23-2016 Hello! I need to restrict access to a controller. I have tried placing a .htaccess file inside the controllers directory with code like this: Code: <FilesMatch "config\.php|function\.php|include\.php"> But it doesn't seem to work How can I restrict access to controller? I hope somebody can point me in the right direction. Best regards. RE: Restrict access to controller - InsiteFX - 11-23-2016 It depends on how you want to restrict the Controller. If you just need to restrict it from the url CI allows an _ ( under_score ) to do that. You can also make the methods in it private. If you want to restrict user access then you will need to create your own method to do that. RE: Restrict access to controller - JackWhite - 11-24-2016 I would like to restrict public access to it, but still be able to run it with a cron job. RE: Restrict access to controller - salain - 11-24-2016 You can use something like this in your __construct PHP Code: public function __construct() RE: Restrict access to controller - JackWhite - 11-25-2016 Thank you! This is perfect for the job (11-24-2016, 12:49 AM)salain Wrote: You can use something like this in your __construct RE: Restrict access to controller - salain - 11-25-2016 You are welcome |