Welcome Guest, Not a member yet? Register   Sign In
Use different 404 page on front-end and back-end
#7

(09-28-2015, 06:33 AM)Martin7483 Wrote:
(09-28-2015, 06:09 AM)Narf Wrote: Actually, it's quite the opposite ... 404_override may be a single value, but it points at what to look for in the current directory and then naturally falls back to the root one.

When you have application/controllers/Error404.php and application/controllers/admin/Error404.php, setting $route['404_override'] to 'Error404' will cause admin/Error404.php to be loaded if you visit /admin/non-existing-uri.

Did not know that, and I believe this is not explained in the user guide

Indeed it wasn't ... https://github.com/bcit-ci/CodeIgniter/c...f694fa3907

But actually, I also said something that's not entirely true:

(09-28-2015, 06:09 AM)Narf Wrote: You can't have different 404 pages if you just call show_404() ... it's obviously the same function no matter what you do.

It's the same function, and you can't change the function itself, but you can modify the error template to display something different based on the first URI segment. Smile

(09-28-2015, 06:51 AM)Lykos22 Wrote:
(09-28-2015, 06:09 AM)Narf Wrote: Actually, it's quite the opposite ... 404_override may be a single value, but it points at what to look for in the current directory and then naturally falls back to the root one.

When you have application/controllers/Error404.php and application/controllers/admin/Error404.php, setting $route['404_override'] to 'Error404' will cause admin/Error404.php to be loaded if you visit /admin/non-existing-uri.

I do have to say this though - you shouldn't 404 based on whether items exist in a list or not. The list itself still exists, even if empty.

So basically if I understand this correct, I can simply create:


Code:
application/controllers/admin/Error404.php

application/controllers/Error404.php

and set in my routes $route['404_override'] = 'Error404';

So basically with this setting if I'm on public site and visit my-site.com/non-existing-uri, I 'll be redirected to Error404, whereas if I access
my-site.com/admin/non-existing-uri, I will be redirected to admin/Error404, am I right ???

Correct.
Reply


Messages In This Thread
RE: Use different 404 page on front-end and back-end - by Narf - 09-28-2015, 07:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB