Add a 404 Not Found to your forum using your portal

Written by Mick in Tutorials on 03 Jul 2010


I hate doing a web search to only find a generic looking 404 not found page.  Well, this code will work on any portal that handles HTML pages, looks good and at the same time no broken or missing pages.




Create an HTML page and name it "404 Not Found".

Add this code to it:


<div class="container404">
  <img src="https://www.idesignsmf.com/images/404.jpg" alt="Page Not Found">
  <div class="centered">
     <p>Wow you found it!! I've been looking for this page since i created it in 2009. Sadly, even though you found this page, I seem to have also misplaced the page you were looking for.</p>
  </div>
</div>


<script type="text/javascript" src="http://linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script>
<script type="text/javascript">
         var GOOG_FIXURL_LANG = 'en';
         var GOOG_FIXURL_SITE = 'https://www.idesignsmf.com'
</script>


The CSS:

.container404 {
    position: relative;
    text-align: center;
    color: #333;
}
.container404 p {
    font-size: 16px
}
.centered {
    position: absolute;
    top: 70%;
    left: 50%;
    transform: translate(-50%, -50%);
}


Replace all URL's, images and text with your own ;)

Open your .htaccess file and add:

ErrorDocument 404 https://www.idesignsmf.com/index.php/page,page4822.html

Replace the link with the link of your own 404 not found page.
Mick is an American theme designer for Simple Machines Forum software currently living in South Florida, USA. He runs idesignSMF and started tinkering with SMF in 2006 where he created several SMF forums of his own before he founded idesignSMF in 2009 to which he is dedicated full time.
    

11 Comments

Nice but mine doesn't seem to redirect to the error page.

.htaccess  ErrorDocument 404 http://www.thetwoworldsforum.com/index.php?page=error404
#1
Will look later,  I'm on my phone and all see is your forum with the iPhone theme/mod.
#2
Quote from: bluedevil on 03 Jul 2010
Will look later,  I'm on my phone and all see is your forum with the iPhone theme/mod.
Ok I use RewriteRule (.*) (page error here) in htaccess instead of ErrorDocument 404 so it now works. :)
#3
Very well DS.

I used ErrorDocument 404 as google recommended.  Pretty cool there is another way around that.



#4
DS, i cant read your post, its blank.

I would think you posted as i was running a maintenance.  :-[
#5
Quote from: bluedevil on 06 Jul 2010
DS, i cant read your post, its blank.

I would think you posted as i was running a maintenance.  :-[
Try this:

QuoteHey BD, I am trying to get them to work on the blocks but the script seem to show in the search bar.  :o I doubt it's a SMF bug, or bad script..

<html>
<head>
<script language="Javascript"><!--

var tl=new Array(



"The requested document isn't here.",

"I've tried everything.",

"And I've got... nothing.",

"I'm really concerned about this.",

"But how concerned can I really be?",

"I'm just a machine.",

"I'm simply trying to serve you.",

"But what you want doesn't even exist!",

"Where does that leave me?",

"I mean, I don't even *know* you.",

"How should I know what you really want?",

"Do you really think I can *guess*...",

"what someone I don't even *know*...",

"wants to find here?",

"*sigh*",

"I'm really kinda bummed about this.",

"But what good does that energy do anyone?",

"There's enough negativity out there as it is.",

"Isn't it better if I just move on with my day?",

"And you too?",

"What's Bonnie's little saying?",

"*Live your dreams. If you don't, someone else will.*",

"Hmm.",

"I could have a dream.",

"I mean, it's not totally out of the question.",

"Hell, I can have this chat with you.",

"Shouldn't I be able to dream?",

"So... what do I want to be when I grow up?",

"Hmm.",

"Well, I certainly wouldn't spend so much time just sitting here.",

"Yeah. I should get out more.",

"Out is a nice place.",

"Or *is* it?",

"Aw, sheesh... what do I know?",

"I'm really sorry to lay all this on you.",

"I mean, it's not your job to deal with my ramblings.",

"And I guess it pretty much *is* my job to serve you.",

"But I couldn't get this one little page for you.",

"I'm so sorry.",

"Augh!",

"Hey...",

"Maybe I could interest you in another page, eh?",

"There are tons around here that are pretty cool, actually.",

"Yeah.",

"Go explore.",

"Have fun.",

"Now.",

"Seriously.",

"You'd better go on now.",

"Please leave me to my thoughts.",

"And my dreams.",

"Yeah."

);

var speed=60;

var index=0; text_pos=0;

var str_length=tl[0].length;

var contents, row;



function type_text()

{

  contents='';

  row=Math.max(0,index-7);

  while(row<index)

    contents += tl[row++] + '\r\n';

  document.forms[0].elements[0].value = contents + tl[index].substring(0,text_pos) + "_";

  if(text_pos++==str_length)

  {

    text_pos=0;

    index++;

    if(index!=tl.length)

    {

      str_length=tl[index].length;

      setTimeout("type_text()",1500);

    }

  } else

    setTimeout("type_text()",speed);



}

//--></script>



<body topmargin="5" onload="type_text()" style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" link="#000000" alink="#006600" vlink="#006600">

<table style="text-align: left; width: 80%; margin-left: auto; margin-right: auto; font-family: Helvetica,Arial,sans-serif;" border="0" cellpadding="2" cellspacing="2">

</table>

<table style="font-family: Helvetica,Arial,sans-serif;" align="center" border="0" cellpadding="10" cellspacing="0" width="753">

</table>

<div style="font-family: Helvetica,Arial,sans-serif;" align="center"><big><b>Error
404<br>

</b></big><br>

<b>The page you are trying to look for
was not found!<br>

<br>

</b> <>

<center style="font-family: Helvetica,Arial,sans-serif;">
<form> <textarea rows="8" cols="60" wrap="soft"></textarea> </form>

</center>

<div style="font-family: Helvetica,Arial,sans-serif;" align="center"><!--DWLayoutTable--><>

<table style="font-family: Helvetica,Arial,sans-serif;" align="center" border="0" cellpadding="2" cellspacing="2" width="753">

<tbody>

<tr>


<td colspan="2" rowspan="1" style="vertical-align: top;"><br>

</td>
</tr>


<tr>

<td colspan="2" rowspan="1" style="vertical-align: top; text-align: center;"><small>©
2009-2010, <a href="http://thetwoworldsforum.com/">Two Worlds</a>, All rights reserved.</small> </td>

</tr>

</tbody>
</table>

</body> </html>
#6
That's odd, I still can't read your post.  Hmmm..
#7
I can see your last post now.  I was able to see your other posts with my phone.

Anywho,   youre using this in a html block?  You mean an html page?


Take the <html>,<head> and <body> codes out of the code since the portal already uses them.
#9
Ok you should see the edit in my previous post. I did what you suggest, the script still shows in the search bar instead inside the textarea
#10

Get more stuff like this

Subscribe to our mailing list and get interesting content and updates.