Home Joomla Custom Joomla 404; file not found page
formats

Custom Joomla 404; file not found page

Published on 24 October 2010 by in Joomla

In the original Joomla 1.5.x 404 page not found file, I missed a search option. So I added the search form to the original. It is possible to redirect your 404 to a article in joomla, but the downside is: you have a searchable 404.

Create a file called error.php in your default template, like so: website_root/templates/own_template/error.php and paste the next code in to it.

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
 
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
<title><?php echo $this->error->code ?> - <?php echo $this->title; ?></title>
<link rel="stylesheet" href="<?php echo $this->baseurl; ?>/templates/system/css/error.css" type="text/css" />
</head>
<body>
<div align="center">
<div id="outline">
<div id="errorboxoutline">
<div id="errorboxheader"><?php echo $this->error->code ?> - <?php echo $this->error->message ?></div>
<div id="errorboxbody">
<p><strong>You may not be able to visit this page because of:</strong></p>
<ol>
<li>An out-of-date bookmark/favourite</li>
<li>A search engine that has an out-of-date listing for this site</li>
<li>A mis-typed address</li>
<li>You have no access to this page</li>
<li>The requested resource was not found</li>
<li>An error has occurred while processing your request.</li>
</ol>
<p><strong>Please try a (new) search on our website:</strong></p>
<p>
<form action="index.php" method="post">
<div class="search">
<input name="searchword" id="mod_search_searchword" maxlength="20" alt="Search" class="inputbox" size="30" value="search..." onblur="if(this.value=='') this.value='search...';" onfocus="if(this.value=='search...') this.value='';" type="text"> <input value="Search" class="button" onclick="this.form.searchword.focus();" type="submit">
</div>
<input name="task" value="search" type="hidden">
<input name="option" value="com_search" type="hidden">
</form>
</p>
<p><strong>Or just try <a href="<?php echo $this->baseurl; ?>/index.php" title="Go to the home page">the home page.</strong></a></p>
<p>If difficulties persist, please contact the system administrator of this site.</p>
<div id="techinfo">
<p><?php echo $this->error->message; ?></p>
<p>
<?php if($this->debug) :
echo $this->renderBacktrace();
endif; ?>
</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
?>
<?php
/**
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
<title><?php echo $this->error->code ?> - <?php echo $this->title; ?></title>
<link rel="stylesheet" href="<?php echo $this->baseurl; ?>/templates/system/css/error.css" type="text/css" />
</head>
<body>
<div align="center">
<div id="outline">
<div id="errorboxoutline">
<div id="errorboxheader"><?php echo $this->error->code ?> - <?php echo $this->error->message ?></div>
<div id="errorboxbody">
<p><strong>You may not be able to visit this page because of:</strong></p>
<ol>
<li>An out-of-date bookmark/favourite</li>
<li>A search engine that has an out-of-date listing for this site</li>
<li>A mis-typed address</li>
<li>You have no access to this page</li>
<li>The requested resource was not found</li>
<li>An error has occurred while processing your request.</li>
</ol>
<p><strong>Please try a (new) search on our website:</strong></p>
<p>
<form action="index.php" method="post">
<div class="search">
<input name="searchword" id="mod_search_searchword" maxlength="20" alt="Search" class="inputbox" size="30" value="search..." onblur="if(this.value=='') this.value='search...';" onfocus="if(this.value=='search...') this.value='';" type="text"> <input value="Search" class="button" onclick="this.form.searchword.focus();" type="submit">
</div>
<input name="task" value="search" type="hidden">
<input name="option" value="com_search" type="hidden">
</form>
</p>
<p><strong>Or just try <a href="<?php echo $this->baseurl; ?>/index.php" title="Go to the home page">the home page.</strong></a></p>
<p>If difficulties persist, please contact the system administrator of this site.</p>
<div id="techinfo">
<p><?php echo $this->error->message; ?></p>
<p>
<?php if($this->debug) :
echo $this->renderBacktrace();
endif; ?>
</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
?>
 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
© Locutus-Web Services
credit