To create a custom 404 error page in PHP login script. You should follow the steps below.
Create a .htaccess file in Apache Server
You should create a .htaccess file and add the following code to direct your server for the 404 page. Change 404.php to any page you want to work as 404 error page.
ErrorDocument 404 /404.php
Similarly in case you want to add custom pages for the other server produced errors.
Common error pages can also be customized In PHP, such as 500, 401, 403
401 – Unauthorized – When your visitor tries to access a password-protected folder, without a valid login.
403 – Forbidden – When your visitor tries to access a URL without a valid file or folder permissions.
500 – Internal Server Error – Appears when having problems with cgi-bin scripts or permission issues.
To configure them, you should add these lines to your .htacess file:
ErrorDocument 500 /500.php
ErrorDocument 401 /401.php
ErrorDocument 403 /403.php