Error | One of the common errors in error handling on the Web is an invalid link. Once an invalid link appears from another site, you will reschedule your
's site. People will save their favorite sites in a book, and if they visit again after three months, only the ' 404 Not Fount '
will not give them task help, tell them how to find the original information from your site. Let's solve this problem, or at least
gives your users a friendly help and can get some traces if they encounter a ' a 404 ' error. You can create an ordinary page to
reports all of the errors encountered while processing your page. PHP and Apache are free to let you create your own error pages, but you need to reconfigure them and make a small number of generations of
code. Let's learn the configuration section first.
Apache's errordocument instructions are used to indicate which document (or URI) Apache should redirect to when an error occurs. It allows you to
specify a resource for each error code that your users may encounter. By adding a errordocument 404 to Your server configuration
/error.php instructions. This will redirect to ' error.php ' when the user accesses a nonexistent page, and we'll write the
' error.php ' page. Don't forget to restart Apache for the changes to take effect.
Then, we write a simple error.php:
the file you requested (<?= $REDIRECT _url?>) does not exist on this server.
Please find the file you want from <a href= "/" > front page </A>.
now try to read a page that doesn't exist on your server, you can see error.php, it has a good and
friendly message, and there is also a link to the previous page.
let's expand it. As you can see, I used the Redirect_url variable in the error.php. This variable is Apache in
executes a errordocument indication, and gives a possibility to find the original resource. In this case, Apache
also sets a number of other variables, all of which can be found here. Using these variables may create a good error page for
User A nice and friendly error page, instead of the default page given by Apache.
output error from PHP page
from a PHP page output error and analog Apache to errordocument instructions to do much like, you simply redirect the user,
by using the query-string variable, and Apache is usually set in the environment variable. This allows you to use the same error page to place the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.