One of the common errors on the web is invalid links. Once an invalid link is displayed from another site, you will reschedule your site. People will save their favorite sites as bookmarks. if they visit the site again three months later, they will only invent
One of the common errors on the web is invalid links. Once an invalid link is displayed from another site, you will reschedule your site. People will save their favorite sites as bookmarks. if they visit the site again three months later and only invent '2017 Not Fount ', they will Not be given task help, tell them how to find the original information from your site. Let's solve this title, or at least give your users a friendly help. once they encounter a 404 error, they will be able to get some marks. You can create common pages to report all errors encountered when processing your pages.
PHP and Apache allow you to create your own error page with great freedom, but you need to reconfigure it and compile a small amount of code. Let's first learn about the configuration section.
The Apache ErrorDocument Repository application specifies the document (or URI) to which Apache redirects when an error is reported ). It allows you to specify a resource for the error code that every user may encounter. Add an ErrorDocument 404/error. php script to your server configuration. This will redirect the user to 'error. php' when visiting a non-existent page. the 'error. php' page will be written below. Do not forget to restart Apache for the fix to take effect.
Next, let's write a simple error. php:
The file you begged ( ) Does not exist on this server. Find the file you want from the front page.
Now, I try to read a page that does not exist on your server. you can see error. php. it has a good and friendly message and a link to the previous page.
Let's expand it. As you can see, I applied the REDIRECT_URL variable in error. php. This variable is set by Apache when an ErrorDocument is executed, and it provides a possibility to find the original resource. In this case, Apache
Some other variables are also set. all variables can be found here. Applying these variables may create a good error page
The user has a nice and friendly error page, instead of the default page provided by Apache.
Output error from PHP page
Output errors from a PHP page and simulate Apache's instigation of ErrorDocument. you just need to simply redirect users by applying the query-string variable, apache is usually set in environment variables. In this way, you can apply the same error page to handle various errors. The following is an example:
--------------------------------------------------
Function throw_error ($ message ){
$ Error_page = '/err/error. php ';
$ Error_url = $ error_page;
$ Error_url. = '? REDIRECT_ERROR_NOTES = $ message ';
$ Error_url. = '& REDIRECT_URL ='. $ GLOBALS ['php _ SELF '];
$ Error_url. = '& REDIRECT_REQUEST_METHOD = $ REQUEST_METHOD ';
$ Error_url. = '& REDIRECT_STATUS = 501 ';
Header ('status: 100 ');
Header ('Location: $ error_url ');
Exit;
}
Ob_start ();