Horje
How to create a custom 404 page PHP HTML CSS

You can set our 404 page that surely fetch to Google as a 404 status.


Just use following code.

Paste following codes which Page You want to show 404.

index.php
Example: PHP
<?php
http_response_code(404);
?>   
<!DOCTYPE html>
<html lang="en"> 
<style>
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #D3D3D3;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.error-container {
    text-align: center;
    background-color: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

h1 {
    font-size: 5rem;
    color: #ff5733;
}

p {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 20px;
}

a {
    text-decoration: none;
    background-color: #ff5733;
    color: #fff;
    padding: 10px 20px;
    border-radius: 3px;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

a:hover {
    background-color: #e6482e;
}    
</style>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, 
                   initial-scale=1.0">
    <title>
        404 Page Not Found
    </title>
    <link rel="stylesheet" 
          href="style.css">
</head>

<body>
    <div class="error-container">
        <h1> 404 </h1>
        <p>
            Oops! The page you're
            looking for is not here.
        </p>
        <a href="https://horje.com">
            Go Back to Home
        </a>
    </div>
</body>

</html>
<?php
exit;
?>

Output should be:

Build a Custom 404 Page

How to set a page as a 404 Status in PHP

Just copy and paste following your pages where you want to show 404 page near Search Engine.

index.php
Example: PHP
<?php
http_response_code(404);
?>   
<?php
exit;
?>




php 404 page

Related Articles
How to add PHP File Get Content PHP URL/LINK Tutorial
How to add PHP cURL CURLOPT PHP URL/LINK Tutorial
How to load XML Sitemap URLs PHP URL/LINK Tutorial
How to get file size from a remote url in PHP PHP URL/LINK Tutorial
How to create a zip file from url using PHP PHP URL/LINK Tutorial
How to create a custom 404 page PHP HTML CSS PHP URL/LINK Tutorial

Single Articles
Build a Custom 404 PagePHP URL/LINK Tutorial
How to set a page as a 404 Status in PHPPHP URL/LINK Tutorial

Read Full:
PHP URL/LINK Tutorial
Type:
Develop
Category:
Web Tutorial
Sub Category:
PHP URL/LINK Tutorial
Uploaded by:
Admin
Views:
66