CodeIgniter Forums

Full Version: Prevent Access to Custom 404 Controller
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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

El Forum

[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.

El Forum

[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.

El Forum

[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.

El Forum

[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.