Results 1 to 3 of 3

Thread: How to design 404 error Page in PHP?

  1. #1
    Join Date
    Feb 2013
    Location
    Chennai
    Posts
    39

    Default How to design 404 error Page in PHP?

    How to design innovative 404 error page in PHP?Thanks in advance

  2. #2

    Default

    In PHP error handling is typically done through you .htaccess file. In .htaccess file has all 404 errors We can include .htaccess file in PHP code then re-direct all 404 errors to a 404.php page. I hope Ayishabanu your problem is solved.

  3. #3
    Join Date
    Apr 2020
    Posts
    704

    Default

    To create a PHP version of custom 404 error page open any text editor of your choice and insert the following code and save it as 404page.php or any other name of your choice but the extension must be .php because here 404 error page is being demonstrated with PHP technology.

    <?php
    header("HTTP/1.0 404 Not Found");
    ?>
    <html>
    <head>
    <title>404 Error - Page Not Found</title>
    </head>
    <body>404 Error - Page Not Found!</body>
    </html>
    Following things you must remember while creating a 404 error page.

    You must specify the 404 HTTP response header in your custom 404 error page else it would be treated as a normal page and 200 OK response will be sent to client browser.
    The header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. In above sample error page the header that starts with the string "HTTP/" (case is not significant) will be used to figure out the HTTP status code to send. Here we have configured Apache to use a PHP script to handle requests for missing files (using the ErrorDocument directive - will be explained shortly), we make sure that our script generates the proper status code.
    The above page is just for demonstration, you can beautify your custom 404 error page as you like and add more relevant content depending upon how much information you want to convey to your audience.

Similar Threads

  1. HTML and CSS Validation: Should You Validate Your Web Page?
    By oolech in forum Web Design Solutions
    Replies: 7
    Last Post: 01-06-2023, 09:52 AM
  2. DNS ps3 error!
    By carmelmonteverdeinn in forum Software & Hardware
    Replies: 5
    Last Post: 06-29-2021, 03:34 PM
  3. What is your favorite way for off page SEO?
    By 1paket.com in forum Web Hosting Community
    Replies: 28
    Last Post: 11-27-2017, 10:38 AM
  4. html colors on my page?
    By jonys in forum Web Design Solutions
    Replies: 10
    Last Post: 11-25-2017, 10:52 AM
  5. Replies: 1
    Last Post: 04-04-2011, 10:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •