Apache error page 404, 403 configuration tutorial_PHP tutorial

WBOY
Release: 2016-07-20 11:15:06
Original
1275 people have browsed it

In PHP website development, when users make an error when accessing the website and cannot find the page, HTTP 404 and 403 error messages will appear. In order to improve the user experience, we need to customize 404 and 403 error pages to prompt the user for the next step or automatically Jump to the appropriate access page.

The method of customizing error pages 404 and 403 is mainly configured through apache or htaccess. The htaccess method of configuring error pages is suitable for virtual host users. The following details the configuration tutorial for error pages 404 and 403.

The methods for setting 404 and 403 error pages in apache and htaccess are basically the same. If you use htaccess for configuration, be sure to enable the htaccess configuration function. For details, please refer to the PHP recommended tutorial: Using apache and htaccess to set password protection for directory access configuration tutorial.

Error page 404, 403 configuration method

1. Open the apache httpd.conf configuration file or create a new .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 new 403.html and 404.html files in the lerrpage folder of the website root directory

Other instructions

You can also automatically jump to the homepage or another website when a 404 or 403 error message appears on the website access page. The method is as follows

ErrorDocument 403 /index.php

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

Of course, due to user experience considerations, it is not recommended to automatically jump to the homepage or other websites.

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/440230.htmlTechArticleIn PHP website development, when the user makes an error while accessing the website and cannot find the page, an HTTP 404,403 error message will appear. , in order to improve user experience, we need to customize 404 and 403 error pages,...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template