Jump to content

404 Page


mike131
 Share

Recommended Posts

I want to change pages where you would get a simple page that says

Unable to complete this request due to an error. Error has been logged. Administrator has been notified.

To show a 404 page in the templates folder instead.

How do I go about doing this?

Thank you!

EDIT:

I do have a 404 page at example.com/404

So for me, there are a bunch of children items under example.com/about, such as

example.com/about/resource

example.com/about/team

I want example.com/about to go to the 404 page since there is nothing there, only the children.

Link to comment
Share on other sites

Check out the folder called “errors” in your template directory. You’ll find 500.html and a readme.txt. This html file will be displayed when a fatal error occurs, and you can customize it.

To manually cause the 404 page to show, you can throw this exception in your template code:

throw new Wire404Exception();

However, it sounds like this recipe might suit your needs better than a 404 error page: First child redirect on ProcessWire Recipes. It’s just a single line:

if($page->numChildren) $session->redirect($page->child()->url);
die();
  • Like 1
Link to comment
Share on other sites

Check out the folder called “errors” in your template directory. You’ll find 500.html and the following readme.txt. This html file will be displayed when a fatal error occurs, and you can customize it.

To manually cause the 404 page to show, you can throw this exception in your template code:

throw new Wire404Exception();

However, it sounds like this recipe might suit your needs better than a 404 error page: First child redirect on ProcessWire Recipes. It’s just a single line:

if($page->numChildren) $session->redirect($page->child()->url);
die();

Thank you so much for this !!

Link to comment
Share on other sites

(I said “the following readme” because I was going to paste it until I saw your edit)

By the way, if you use a template without a file, pages using that template will show the 404 page automatically. You should probably look into what’s causing the error in /about/’s template.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...