Hack Forums
[MyBB] Custom 404 Page Without Plugins! - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141)
+---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50)
+---- Thread: [MyBB] Custom 404 Page Without Plugins! (/showthread.php?tid=4065786)



[MyBB] Custom 404 Page Without Plugins! - • α∂∂ιcтιση • - Feb 17, 2014

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.


* - hitincreaser - Feb 17, 2014

I found a error your naming the file pagenotfound.php but then in htaccess your calling it filenotfound.php ??


* - • α∂∂ιcтιση • - Feb 17, 2014

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


* - Red™ - Mar 2, 2014

I followed everything but the content doesnt show up, do you know whats causing this problem?
http://www.gamingpalace.net/bans.php


* - • α∂∂ιcтιση • - Mar 3, 2014

That page gives a 404 not found error, which it is supposed to.


* - Hуѕтєяιa X™ - Mar 3, 2014

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


* - Red™ - Mar 4, 2014

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


* - • α∂∂ιcтιση • - Mar 4, 2014

Post your code here and i'll take a look at it.


* - Red™ - Mar 4, 2014

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>



* - HostSlayer - Mar 4, 2014

This should help out some beginners. I do it a little different though.


* - • α∂∂ιcтιση • - Mar 14, 2014

Thanks man, it was intended for the entry level MyBB user anyway :p