Apache error page 404 and 403 configuration tutorial

Source: Internet
Author: User
Tags php website password protection

During PHP website development, an HTTP 404,403 error occurs when a user fails to access a website or fails to find a page. To improve user experience, we need to customize the 404 and 403 error pages, prompt the user to perform the next step or automatically jump to the appropriate access page.

The custom error page 404 and 403 methods are mainly configured through apache or htaccess. The htaccess configuration error page method is suitable for VM users. The following describes the configuration tutorial of error pages 404 and 403 in detail.

The methods for setting 404 and 403 error pages for apache and htaccess are basically the same. If you use htaccess for configuration, enable the htaccess configuration function. For details, refer to the recommended PHP Tutorial: tutorial on Setting Password protection for directory access using apache and htaccess.

Error Page 404, 403 configuration method

1. Open the apache httpd. conf configuration file or create a. htaccess configuration file.

2. Add the following information:
ErrorDocument 403/errpage/403.html

ErrorDocument 404/lerrpage/404.html

3. Save the apache httpd. conf or htaccess configuration file and restart apache.

4、create 403.html and 404.html files under the lerrpagefolder of the website root directory

Other Instructions

You can also automatically jump to the home page or another website when Error 404 or 403 is displayed on the website access page. The method is as follows:

ErrorDocument 403/index. php

ErrorDocument 404 http://www.minimalart.cn
The configuration information above is set to automatically jump to the homepage of the website when an HTTP 403 error occurs, and automatically jump to PHP tutorial network when an HTTP 404 error occurs.

Of course, for the sake of user experience, it is not recommended to automatically jump to the home page or other website settings.

Now the configuration of error pages 404 and 403 is completed through apache or htaccess.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.