php redirect page not found to 404.php code example

Example: how to redirect 404 error page in php

Try this in your .htaccess:

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

Tags:

Misc Example