1. Create Custom 404 Error

Create Custom 404 Error

  |   17
Create Custom 404 Error404 Error page in Datalife Engine is handling by internal 404 error message which built-in with it, when you visit some page that don't exist you will get error message which is translated in language file /language/language_name/website.lng for example:
- Requested page was not found.
- No articles found or you do not have access to them.
- The article cannot be found. Probably article URL has been changed. Please use search.

Those are main 404 error messages in DLE, so when you access to page that don't exist DLE simply draw one of those messages into the theme file that handle the site information "info.tpl" which only display messages the specified by DLE error handling...What if you want you create your own 404 error page without using the internal error, and want to add more details with design any way you want and in cases many people would love to put advertising on the 404 error to make money out of it?

You can do that, here is the step how to add custom 404 error page into your Datalife Engine website...
  1. Create the php file lets name it "404.php" (the file to use should be php as I would recommend (but .html is fine too but I will not recommend in DLE site), if you don't know how to make it, you can use any html editor and make your own style using regular html code and save it as .php)
  2. Place (upload) your 404.php in root of your website like this:
    http://www.yoursite.com/404.php
  3. Open .htaccess file located in your directory root and add this code next line to "RewriteEngine On"
    ErrorDocument 404 /404.php

    Note: /404.php is the name of the file you want to use, if you name something else then make sure you change them in every step in this tutorial

  4. (DLE 10.x please skip this step!) Open /engine/modules/show.short.php and find:
    msgbox( $lang['all_err_1'], $lang['news_err_27'] );
    Replace with:
    require_once ROOT_DIR.'/404.php';die();

    Note: there are 2 of this line, so replace both

  5. (For DLE 10.x only!) Open /index.php and find:
    msgbox( $lang['all_err_1'], $lang['news_err_27'] );
    Replace with:
    require_once ROOT_DIR.'/404.php';die();
  6. Open /engine/modules/show.full.php and find:
    msgbox( $lang['all_err_1'], $lang['news_err_12'] );
    Replace with:
    require_once ROOT_DIR.'/404.php';die();
  7. Open /engine/modules/static.php and find:
    msgbox( $lang['all_err_1'], $lang['news_page_err'] );
    or (10.x)
    msgbox( $lang['all_err_1'], $lang['static_page_err'] );
    Replace with:
    require_once ROOT_DIR.'/404.php';die();
Now when you try to access the page that don't exist, you will see the page 404.php instead, in this page I would like to recommend that you add "Go Back" link or button within the file because this 404 error page is no longer part of DLE, so it will redirect you to outside DLE website, only cookie remains in the website and browsers when you click go back you still remain logged in.
Dear visitor, you are browsing our website as Guest.
We strongly recommend you to register and login to view hidden contents.

Details

+16

Comments 17

noobos
noobos
DLE TEAM
Commented By noobos on October 31, 2011 (4:39 am)
good hack bro... beer2
16 302Forum topics : 12Forum replies : 1036Forum likes : 170
tbenmcp
tbenmcp
DLE TEAM
Commented By tbenmcp on October 31, 2011 (4:57 am)
my goodness sawan, you are terrible in spelling my friend...hahaha...I got bunch of error report on your post hahaha...do you live in America for too long buddy applause
20 150Forum topics : 11Forum replies : 248Forum likes : 32

"A True Friend is Someone Who Sees the Pain in Your Eyes while Everyone Else Believes the Smile on Your Face"
Let me Google for you!
sawanbanna
sawanbanna
DLE TEAM
Commented By sawanbanna on October 31, 2011 (5:43 am)
I know I am suck dude but well, got to help me out if I misspell laughing
31 409Forum topics : 23Forum replies : 979Forum likes : 150

« Live as if you were to die tomorrow. Learn as if you were to live forever! »
user
user
Members
Commented By user on October 31, 2011 (2:09 pm)
i LIKE this tut sawan applause
4 12Forum topics : 1Forum replies : 6Forum likes : 0
tbenmcp
tbenmcp
DLE TEAM
Commented By tbenmcp on November 3, 2011 (5:57 pm)
haha...that's good you like it..sawan only write the quality topic with something people don't actually find easily...that's his goal to make our site better than anyone else...
20 150Forum topics : 11Forum replies : 248Forum likes : 32

"A True Friend is Someone Who Sees the Pain in Your Eyes while Everyone Else Believes the Smile on Your Face"
Let me Google for you!
sawanbanna
sawanbanna
DLE TEAM
Commented By sawanbanna on November 6, 2011 (1:39 am)
user,
Thanks man...
31 409Forum topics : 23Forum replies : 979Forum likes : 150

« Live as if you were to die tomorrow. Learn as if you were to live forever! »
jopaulmj
jopaulmj
V.I.P.
Commented By jopaulmj on August 7, 2012 (8:53 pm)
Google recommend this code past in 404.php



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

5 26Forum topics : 0Forum replies : 0Forum likes : 0
Commented By hiroshimamovies on December 1, 2012 (4:47 am)
I have this in my /engine/modules/show.full.php

msgbox( $lang['all_err_1'], "<b>{$user_group[$member_id['user_group']][
;'group_name']}</b> " . $lang['news_err_28'] );


I must replace with this ?
require_once ROOT_DIR.'/404.php';die();
3 49Forum topics : 111Forum replies : 338Forum likes : 2
noobos
noobos
DLE TEAM
Commented By noobos on December 1, 2012 (2:14 pm)
hiroshimamovies,
the error message you indicated was for article existing but don't have access by specific user groups, this is valid URL not error 404, if you want to change it, then you should change the message in language file instead.
news_err_28
16 302Forum topics : 12Forum replies : 1036Forum likes : 170
asaadshaikh
Commented By asaadshaikh on January 10, 2013 (10:38 am)
hello

i replaced all of the codes above but when ever i try to navigate i get

Oops! This link appears to be broken.


for example

if i try to go to

http://sysfilmpro.tk/softwares/
3 43Forum topics : 14Forum replies : 30Forum likes : 0
noobos
noobos
DLE TEAM
Commented By noobos on January 11, 2013 (12:47 am)
you don't have 404.php or error page in your root of your server...
16 302Forum topics : 12Forum replies : 1036Forum likes : 170
asaadshaikh
Commented By asaadshaikh on January 11, 2013 (1:10 am)
noobos,

i have it........

by the way i have 9.7
3 43Forum topics : 14Forum replies : 30Forum likes : 0
noobos
noobos
DLE TEAM
Commented By noobos on January 11, 2013 (1:15 am)
no you don'\t have it on your root...

http://sysfilmpro.tk/404.php

there is nothing there only single link to javascript file, there is not execute script, that's how you get blank page.
16 302Forum topics : 12Forum replies : 1036Forum likes : 170
ContactUs
ContactUs
V.I.P.
Commented By ContactUs on February 7, 2013 (2:21 pm)
We can try this hack in different way also (if it is not wrong a wrong way):

can we use error.html (custom page through dle adminpanel) and redirect 404.php to error.html
with this code:

<?php

   header( 'Location: http://mydomain.com/error.html' ) ;

?>
N/A 11Forum topics : 14Forum replies : 46Forum likes : 0
noobos
noobos
DLE TEAM
Commented By noobos on February 7, 2013 (3:00 pm)
ContactUs,
I am not sure I understand you totally...but if you mean by you want to use .html instead of .php then the answer is yes, you can use php,html,html,cgi or any compatible to display on any browsers as long as your server support those files.
16 302Forum topics : 12Forum replies : 1036Forum likes : 170
admpe
admpe
Members
Commented By admpe on February 8, 2015 (1:56 am)
Is it work for DLE 10.3 ? look
N/A 4Forum topics : 0Forum replies : 0Forum likes : 0
yorismith
yorismith
Moderators
Commented By yorismith on February 8, 2015 (9:36 pm)
Quote: admpe
Is it work for DLE 10.3 ? look

It should work with all versions
32 288Forum topics : 2Forum replies : 699Forum likes : 117

- Nothing comes free...
- A generous heart, kind speech, and compassion are the things which renew humanity
Information!Would you like to leave your comment? Please Login to your account to leave comments. Don't have an account? You can create a free account now.
DLEStarter Notice!Please note...Every hack and every module will get additional queries from your database and some hacks and some modules may result your server overload, so install only what you "need", remove any hacks and modules from your script when you don't need them, all hacks and modules appears in this website are not guaranteed by DLEStarter Team for your script security and compatibility, please read instruction carefully and use hacks and modules at your own risk...Thank you.