-3

While creating 404 error page the page contents of other pages can be modified and it is created . But how to do it?

After creating 404 error pages , explain how to redirect it.

How to rectify the broken links?

  • see [How can I create an error 404 in PHP?](http://stackoverflow.com/questions/1381123/how-can-i-create-an-error-404-in-php) – Satish Sharma Aug 07 '14 at 05:51
  • 1
    In general: The same way as any other page… and then you tell your (unspecified so we can't go into specifics) HTTP server that the file should be used for 404 errors. – Quentin Aug 07 '14 at 05:51

1 Answers1

1

Custom Error Page with Apache 2.2+ and PHP

.htaccess or vhost settings:

# in .htaccess you need AllowOverride in the /error directory
ErrorDocument 404 /error/404.php

Custom Error Page with Nginx and PHP

add the part below in your nginx server config like: (/usr/local/nginx/conf/nginx.conf)

error_page 404 /404.php;
location  /404.php {
  internal;
}

Custom Error Page with lighttpd and PHP

add the script below in your lighttpd config:

server.errorfile-prefix = "/srv/www/htdocs/errors/status-" 

and make error pages with the syntax like:

/srv/www/htdocs/errors/status-404.php
/srv/www/htdocs/errors/status-500.php

404.php

header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
echo 'The Page'. $_SERVER["HTTP_REFERER"]. ' cannot be found!';

More Infos about this

spinsch
  • 1,415
  • 11
  • 23
  • **Check this Working Concept** [Click Here](http://stackoverflow.com/questions/1381123/how-can-i-create-an-error-404-in-php/36306284#36306284) – Irshad Khan Mar 30 '16 at 10:36