how to get response 404 error page in php code example
Example 1: how to check website 404 status in php
<?php
$url = 'http://google.com';
if(@file_get_contents($url)){
echo "Website is up";
} else {
echo "Website is down";
}
?>
Example 2: how to redirect 404 error page in php
Try this in your .htaccess:
ErrorDocument 404 http:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ <YourRelativePathToPHPFile>/404.php [L]
Here,The ErrorDocument redirects all 404s to a specific URL
The Rewrite rules map that URL to your actual 404.php script. The RewriteCond regular expressions can be made more generic if you want, but I think you have to explicitly define all ErrorDocument codes you want to override.
NOTE: Replace