WordPress.org

Ready to get started?Download WordPress

Forums

Is it possible to have two types of 404 errors? per directory? (5 posts)

  1. luxman
    Member
    Posted 1 year ago #

    I am using a child-theme, which has it's own custom 404 message.

    However, I would like to use a second one for regular/custom pages that I am adding to the site... So I was curious to know if there's a way for me to create/add a SECOND 404 page within a specific directory.

    for example:

    http://www.mysite.com/blog/sdfsdfdsf = regular 404
    http://www.mysite.com/about/sdfsdfds = regular 404
    http://www.mysite.com/custom/sdfdsf = custom 404 page

  2. luxman
    Member
    Posted 1 year ago #

    I tried:

    ErrorDocument 404 custom/404.html

    within the .htaccess file but nothing happens... Plus I think that would just override everything to 1 404 page, not the two that I want?

  3. catacaustic
    Member
    Posted 1 year ago #

    That's not the way to do it.

    The best way that I can think of is to set up some conditions in your existing 404 page that can check to see if the page/post/cateogry/taxonomy/etc is in the list that you want to target. if it is, show them the second content, and if not show the first content.

  4. luxman
    Member
    Posted 1 year ago #

    Not sure what you mean by that...

    I created another .htaccess with ErrorDocument 404 /custom/404-old.php

    and placed it in the /custom/ folder but it still shows the generic 404 template.

  5. catacaustic
    Member
    Posted 1 year ago #

    I said... That's not the right way to do it. Because of the standard WP .htaccess rules, any 404 errors are handled by the WordPress system so your server will never see yur additional 404 document.

    To set it up, look at what's in your current 404.php file in your theme. In there there will be a few checks, and some code to display whatever error notice that there is now. My suggestion was to use some of the WP functions to check what the user expected and display content based on that. It will take a bit of programming still, and a few trial and error attempts because you'll always figure out something that's not owrking quite the way that you wanted it to.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags