CodeIgniter Forums
Prevent Access to Custom 404 Controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Prevent Access to Custom 404 Controller (/showthread.php?tid=53780)



Prevent Access to Custom 404 Controller - El Forum - 08-08-2012

[eluser]fjamal[/eluser]
I have a custom '404 Not Found' page handled by Custom404 controller.

Unfortunately, custom404 can be accessed directly via URL as http://www.example.com/ci_proj/custom404

I want to prevent custom404 to be accessed directly via URL, so i decided to put it under a folder and set .htaccess for the folder.

I put custom404 into a folder named 'my_error_page' and then fixed
Code:
$route['404_override'] = 'custom404';
to
Code:
$route['404_override'] = 'my_error_page/custom404';

NOTE: custom404.php resides under applications/controllers along with other controllers such as home, etc.

When i type a wrong controller name for the sake of testing, i don't get the 404 page anymore. I get this error:

Quote:Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.

Any idea how to prevent user's from accessing Custom404 controller? I do not want to do it via _remap.

Thanks




Prevent Access to Custom 404 Controller - El Forum - 08-08-2012

[eluser]Aken[/eluser]
What's the difference? It's still going to come up as a 404 page, just like any other 404 page. The user sees the exact same thing.


Prevent Access to Custom 404 Controller - El Forum - 08-09-2012

[eluser]fjamal[/eluser]
[quote author="Aken" date="1344492058"]What's the difference? It's still going to come up as a 404 page, just like any other 404 page. The user sees the exact same thing.[/quote]

Just curious on how to prevent user from accessing a specific controller. Anyhow, its not a big deal; it could be done via sessions.


Prevent Access to Custom 404 Controller - El Forum - 08-09-2012

[eluser]Aken[/eluser]
You can prevent access to certain controllers in various ways - protected/private method assignment, underscore prefix in the method name, etc. There's no real point to blocking access to the 404 controller, though, since it'll output exactly the same thing as any other 404 page that doesn't exist.


Prevent Access to Custom 404 Controller - El Forum - 08-11-2012

[eluser]fjamal[/eluser]
[quote author="Aken" date="1344576093"]You can prevent access to certain controllers in various ways - protected/private method assignment, underscore prefix in the method name, etc. There's no real point to blocking access to the 404 controller, though, since it'll output exactly the same thing as any other 404 page that doesn't exist.[/quote]

I agree, its pointless.