what is 404.php

Web programming topics
Post Reply
User avatar
Face
Major
Major
Posts: 727
Joined: Thu Feb 18, 2010 5:06 pm
Location: SRI LANKA.KANDY.

what is 404.php

Post by Face » Sat May 14, 2011 11:14 pm

I start word press theme studies,(you know about that :P),

I asked about to give me some ideas to start.then shane told that better to get a theme & start studding about that.thanks shane.I started it now.little late :D

I wanna know some littel things.it will be help full for my studies.

In every theme I found a flie named 404.php
I wanna know what is that & is that a must in a web project?

Code: Select all

<?php
/**
 * The template for displaying 404 pages (Not Found).
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */

get_header(); ?>

	<div id="container">
		<div id="content" role="main">

			<div id="post-0" class="post error404 not-found">
				<h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1>
				<div class="entry-content">
					<p><?php _e( 'Apologies, but the page you requested could not be found. Perhaps searching will help.', 'twentyten' ); ?></p>
					<?php get_search_form(); ?>
				</div><!-- .entry-content -->
			</div><!-- #post-0 -->

		</div><!-- #content -->
	</div><!-- #container -->
	<script type="text/javascript">
		// focus on search field after it has loaded
		document.getElementById('s') && document.getElementById('s').focus();
	</script>

<?php get_footer(); ?>
I got tewntyten theme to do my studies.the most famous theme in wordpress & the default theme.

I wanna know about 404 & then I will make a 404 to my simple wordprss theme.
User avatar
Herath
Major
Major
Posts: 417
Joined: Thu Aug 05, 2010 7:09 pm

Re: what is 404.php

Post by Herath » Sun May 15, 2011 12:15 am

It is the page to be displayed when a HTML 404 (Page not found) error occurs. :)
Simple as that.
ba01
Corporal
Corporal
Posts: 3
Joined: Tue Nov 08, 2011 12:59 pm

Re: what is 404.php

Post by ba01 » Tue Nov 08, 2011 4:57 pm

hey you know Website error pages (404) are perhaps one of the most overlooked pieces of a fully rounded website. Not only are they important but they give you the opportunity to have a little fun. Although many web developers rely on server logs to keep an eye out for hits on error pages, I’m going to take a different approach by using a PHP generated email. In addition, we will spice up the design a bit, add basic navigation and link to the website sitemap.
User avatar
miteshaegis
Posts: 2
Joined: Fri Dec 07, 2012 3:10 pm

Re: what is 404.php

Post by miteshaegis » Fri Dec 07, 2012 5:29 pm

When generate 404 error than understood something wrong in url so you can check your url.
evangilbort
Sergeant
Sergeant
Posts: 12
Joined: Fri Jun 21, 2013 12:19 pm

Re: what is 404.php

Post by evangilbort » Fri Jun 21, 2013 2:08 pm

I am trying to in my header file and i want to see 404 is working in PHP I have write this code :

<?php
if (pageNotInDatabase) {
header('Location: ' . $_SERVER["REQUEST_URI"] . '?notFound=1');
exit;
}

But when I go to that page, nothing comes up. Is this something I have to explicitly set in Apache? I just want to be able to show a 404.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: what is 404.php

Post by Neo » Tue Jun 25, 2013 4:15 am

Try this

Code: Select all

<?php
if (pageNotInDatabase) {
     header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
    echo "<h1>404 Not Found</h1>";
    echo "The page that you have requested could not be found.";
    exit();
} 
evangilbort
Sergeant
Sergeant
Posts: 12
Joined: Fri Jun 21, 2013 12:19 pm

Re: what is 404.php

Post by evangilbort » Tue Jun 25, 2013 4:06 pm

Thank's Neo. This code will be executed the program and given output perfectly.
Post Reply

Return to “Web programming”