Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

[MyBB] Custom 404 Page Without Plugins!

First of all, you're gonna want to add this code to the last line on your .htaccess file.

Code
ErrorDocument 404 /filenotfound.php

Now, you want to create a new page, called 'filenotfound.php' and add this code to it.

Code
<?php     define('IN_MYBB', 1);
    require_once("global.php");

    add_breadcrumb("404 Error", $_SERVER['PHP_SELF']);

    eval("\$page = \"".$templates->get("404")."\";");

    output_page($page);
?>

Now, upload the filenotfound.php file to your main website's directory.

Then, create a new template on your main theme with the name 404 and add this to it:

Code
<html>
<head>
<title>Your title</title>
{$headerinclude}
</head>
<body>
{$header}
Your 404 Page Content
{$footer}
</body>
</html>

Edit where it says Your 404 Page Content to whatever suits your needs.
I found a error your naming the file pagenotfound.php but then in htaccess your calling it filenotfound.php ??
(Feb 17, 2014 06:32 AM)hitincreaser Wrote:  I found a error your naming the file pagenotfound.php but then in htaccess your calling it filenotfound.php ??

Whoops, sorry about that. Thanks for noticing, fixed it.
I followed everything but the content doesnt show up, do you know whats causing this problem?
http://www.gamingpalace.net/bans.php
[Image: YFNJZfM.gif]
That page gives a 404 not found error, which it is supposed to.
(Mar 2, 2014 10:27 PM)Red™ Wrote:  I followed everything but the content doesnt show up, do you know whats causing this problem?
http://www.gamingpalace.net/bans.php

"{$header}
Your 404 Page Content
{$footer}"

You never put anything where it says "Your 404 content" thus it's a blank page. Your bread crumb is right as it states 404 error.
(Mar 3, 2014 04:17 PM)Hуѕтєяιa X™ Wrote:  "{$header}
Your 404 Page Content
{$footer}"

You never put anything where it says "Your 404 content" thus it's a blank page. Your bread crumb is right as it states 404 error.

I did put text where it says to put it but its not showing.
[Image: YFNJZfM.gif]
Post your code here and i'll take a look at it.
Here is the code that I am using:

Code
<html>
<head>
<title>Gaming Palace - 404 ERROR</title>
{$headerinclude}
</head>
<body>
{$header}
Oops! It looks like you have tried accessing a non-existing page. This error is caused because the page does not exist.
{$footer}
</body>
</html>
[Image: YFNJZfM.gif]
This should help out some beginners. I do it a little different though.
Thanks man, it was intended for the entry level MyBB user anyway :p


Possibly Related Threads...
Thread / Author Replies Views Last Post
[MyBB] by SkullTraillMay 4, 2021 10:08 AM 18 576 May 4, 2021 10:08 AM
Last Post: Tyr
by IandI187Jul 23, 2019 04:25 PM 2 125 Jul 23, 2019 04:25 PM
Last Post: camden ©
[MyBB] by emotionullJan 21, 2019 01:18 PM 12 457 Jan 21, 2019 01:18 PM
Last Post: Disease