Prevent Controller from executing

I have an acl that is running in MY_Controller. If permission is denied, then at the moment, I just do a redirect('denied') - this is a very basic controller that loads a very basic view saying 'Permission denied'.

However, what I would like to do instead, is still load the originally requested uri, but load the 'denied' view instead of the default view.

I can do this in MY_Controller, and the denied view loads fine. However, this does not stop the original controller/method from executing as well, so I get both views loaded. I also tried putting an exit; statement in MY_Controller after loading the denied view, but this is not workable because then the output does not fire in CI.

Is it perhaps possible to do this via a pre_constructor_controller hook? I couldn't figure out a way to prevent the controller from executing...


You have to let the controller execute in order to let the requested URI load.

After you check the ACL in MY_Controller and if it is not permitted, you can load the denied view there, but you need to do one more thing before you exit.

$this->load->view('denied'); $this->output->_display(); exit();


  • Request map direct me to Login page in Grails
  • Fastest way to save/load data.table
  • R matching more than 2 conditions and return the response value
  • How do I install these PHP extensions on Ubuntu?
  • Installing SSL cert on Amazon EC2 ELB
  • In Akka, is ActorContext thread safe?
  • How to use the resource module to measure the running time of a function?
  • Upload file that is in the cpan database
  • Getting the scrolling offset when storing coordinates
  • Retrieve IP address of device
  • Who propagate bugfixes across branches (corporate development)?
  • xcode don't localize specific strings
  • C# program and C++ DLL compiled for 32-bit system crash on 64-bit system
  • cygwin cannot exec 'git-add--interactive' permission denied
  • Android Google Maps API v2 start navigation
  • Code in Job's Script Block after Start-Process Does not Execute
  • Loading .coffee files via a view in Rails
  • System.InvalidCastException: Specified cast is not valid
  • Sort List of Strings By Version
  • Create DicomImage from scratch using Dcmtk
  • How to set ini file attributes during an Inno install
  • Dialing with Intent.ACTION_CALL stopps at # in phone number
  • ilmerge with a PFX file
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Spray.io: When (not) to use non-blocking route handling?
  • Sony Xperia Z Tablet not found by adb
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Modifying destination and filename of gulp-svg-sprite
  • javascript inside java/jsp code
  • Trying to switch camera back to front but getting exception
  • How can I estimate amount of memory left with calling System.gc()?
  • GridView Sorting works once only
  • SetUp method failed while running tests from teamcity
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Free memory of cv::Mat loaded using FileStorage API
  • Hits per day in Google Big Query
  • Angular 2 constructor injection vs direct access
  • Programmatically clearing map cache
  • Running Map reduces the dimensions of the matrices
  • How to load view controller without button in storyboard?