MyBB Community Forums

Full Version: 404 pages - Make your file not found page blend with your forum
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
OK guys, I'm not a coder, so I won't be able to support this hack. Having said that, let's get to it.

This will allow someone in your forum to type www.leftfordeadforum.com/whole-bunch-of-text
and instead of a default ugly 404 page, it will serve up a fully themed error page, that has a search box right there. Man, the people are gonna go wild for this Cool


1. You'll need to make a new global template
Admin CP > Templates > Modify / Delete > Expand "Global Templates" > Add template

and paste this in it
<html>
<head>
<title>404 File Not Found : {$mybb->settings[bbname]}</title>
{$headerinclude}
</head>
<body>
{$header}
<br />
<table width="100%" border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead">  <strong>File Not Found</strong></td>
</tr>
<tr>
<td height="100" valign="top" class="trow1">Oh No!  It appears that the page you are looking for is either missing, or has moved.  Try searching in the box below to find what you need.</td>
</tr>
</table>

<div>
<br />
<br /></div>

<form method="post" action="./search.php">
<input type="hidden" name="action" value="do_search" />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td colspan="2" class="thead"><strong>{$mybb->settings['bbname']} - {$lang->search}</strong></td>
</tr>
<tr>
<td class="tcat" width="50%"><strong>{$lang->search_keyword}</strong></td>
<td class="tcat" width="50%"><strong>{$lang->search_username}</strong></td>
</tr>
<tr>
<td class="trow1">
<table><tr>
<td valign="top"><input type="text" class="textbox" name="keywords" size="35" maxlength="250" /></td>
</tr>
<tr>
<td>
<span class="smalltext"><input type="radio" class="radio" name="postthread" value="1" checked="checked" />{$lang->search_entire_post}<br /><input type="radio" class="radio" name="postthread" value="2" />{$lang->search_titles_only}</span></td>
</tr></table>
</td>
<td class="trow1">
<table><tr>
<td class="trow1"><input type="text" class="textbox" id="author" name="author" size="35" maxlength="{$mybb->settings['maxnamelength']}" /><br /><span class="smalltext"><input type="checkbox" class="checkbox" name="matchusername" value="1" checked="checked" />&nbsp; {$lang->match_username}</span></td>
<td class="trow1">&nbsp;</td>
</tr></table>
</td>
</tr>

<tr>
<td class="trow1" rowspan="5">{$srchlist}</td>
<td class="trow1">

<select name="postdate">
<option value="0">{$lang->find_anydate}</option>
<option value="1">{$lang->find_yesterday}</option>
<option value="7">{$lang->find_lastweek}</option>
<option value="14">{$lang->find_2weeks}</option>
<option value="30">{$lang->find_month}</option>
<option value="90">{$lang->find_3months}</option>
<option value="180">{$lang->find_6months}</option>
<option value="365">{$lang->find_year}</option>
</select>&nbsp;&nbsp; <input type="radio" class="radio" name="pddir" value="1" checked="checked" />{$lang->and_newer}  <input type="radio" class="radio" name="pddir" value="0" />{$lang->and_older}
</td>
</tr>
<tr>
<td class="tcat"><strong>{$lang->sorting_options}</strong></td>
</tr>
<tr>
<td class="trow1">
<select name="sortby">
<option value="lastpost">{$lang->sort_lastpost}</option>
<option value="starter">{$lang->sort_author}</option>
<option value="forum">{$lang->sort_forum}</option>
</select> {$lang->sort_in} <input type="radio" class="radio" name="sortordr" value="asc" />{$lang->sort_asc} <input type="radio" class="radio" name="sortordr" value="desc" checked="checked" />{$lang->sort_desc} {$lang->sort_order}
</td>
</tr>
<tr>
<td class="tcat"><strong>{$lang->display_options}</strong></td>
</tr>
<tr>
<td class="trow1">{$lang->show_results_as} <input type="radio" class="radio" name="showresults" value="threads" checked="checked" />{$lang->show_results_threads} <input type="radio" class="radio" name="showresults" value="posts" />{$lang->show_results_posts}</td>
</tr>
</table>
<div align="center"><br /><input type="submit" class="button" name="submit" value="{$lang->search}" /></div>
</form>
<br />
<div align="right"><br /> 404 page coded by <a href="http://www.leftfordeadforum.com" target="blank">Left 4 Dead forum</a></div>


{$footer}
</body>
</html>
- feel free to remove the link to my forum if you'd like Blush

2. Upload the attached 404.php into your forum root
[attachment=11868]

3. Add this to the htaccess file in your forum's root (or create a .htaccess if you don't have one)
ErrorDocument 404 /404.php

That's it, you're done!

In the interest of full disclosure, I was able to put this together based on the work of others, mainly through this thread
Hm, I like it. I'll do this, thanks. Smile
Nice, exactly what I was looking for.

Small note to others trying this (although it should be clear to most):
* The new template should have "404" as title
* Make sure you do a right click > save as on 404.php (I messed up the download on first try Smile)
I'm glad others were able to use this!
I may use this later Wink
(2009-02-25, 03:19 AM)Elegant Totality Wrote: [ -> ]I may use this later Wink

Same. Looks very cool.
I'll test this on localhost and see how it works out. Wink