I need help in php. I am making one portal website in Core Php. I had created 404 page and .htaccess file.
404.php:
JavaScript
x
<html>
<head>
<title>404 Error - Page Not Found</title>
</head>
<body>404 Error - Page Not Found!</body>
</html>
.htaccess:
JavaScript
Redirect 404 /404.php
But this is not working. If I use this code:
JavaScript
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /404.html [L]
</IfModule>
It shows internal server error.
Here is my website: http://jobguide.australianenglishcenter.com/
Advertisement
Answer
Try this in your .htaccess:
JavaScript
ErrorDocument 404 http://jobguide.australianenglishcenter.com/404/
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