APACHE AcceptPathInfo instructions

Source: Internet
Author: User
The acceptpathinfo is removed from servers above APACH2.0.30. if necessary, add the AcceptPathInfoOn Apache

When I learned zfdemo, I mentioned setting the AcceptPathInfo command.

Sometimes, when we perform virtual static or make the path look pretty, we may see. For apache, whether the above address runs correctly depends on the configuration of the AcceptPathInfo command.

AcceptPathInfo command

Indicates whether to accept requests with redundant path name information
Syntax AcceptPathInfo On | Off | Default
Default value: AcceptPathInfo Default
Scope: server config, virtual host, directory,. htaccess
Overwrite FileInfo
Status core (C)
Module core
Compatibility is only available in Apache 2.0.30 and later versions.

This command determines whether to accept requests that follow the redundant path name information after the actual file name (or a non-existent file in the actual directory. The redundant path name information can be passed to the script as the PATH_INFO environment variable.

For example, assume that the directory to which/test/directs only contains one File: here.html, the PATH_INFO environment variable is set to "/more" for/test/here.html/more and/test/nothere.html/more requests ".

Value range of the AcceptPathInfo command:

Off
It is accepted only when a request is mapped to a real path. In this way, a "404 not found" error will be returned for requests that follow a path name after a real file name, such as/test/here.html/more.
On
The request can be accepted as long as the leading path can be mapped to a real file. In this way, as long as the above/test/here.html can be mapped to a valid file, requests for/test/here.html/more will be received.
Default
The processor determines whether to receive requests with redundant path name information. The core processor corresponding to the common text rejects PATH_INFO by default. The processor used for servo scripts, such as cgi-script and isapi-isa, accepts PATH_INFO by default.
The primary purpose of the AcceptPathInfo command is to allow you to overwrite the default settings of the processor about whether to accept PATH_INFO. This coverage is necessary. For example, if you use a filter such as Des to generate content based on PATH_INFO. The core processor usually rejects such a request, and you can use the following configuration to make such a script possible:

Options + des
SetOutputFilter between Des
AcceptPathInfo On

In apache 2.0 or later, the default value is no acceptpathinfo.

The acceptpathinfo is removed from servers above APACH2.0.30. if necessary, add the AcceptPathInfo On in http. conf. That is, the original

Options FollowSymLinks includes
AllowOverride None
Change
Options FollowSymLinks includes
AllowOverride None
AcceptPathInfo On

This command determines whether to accept the path information appended to a specified file (or a non-existent file in an existing directory. This path information will appear in the form of The PATH_INFO environment variable in the script.
For example, assume that the directory to which/test/points contains only one file: here.html. Then, the PATH_INFO variable like/more will be obtained for/test/here.html/more and/test/nothere.html/more requests.
The three parameters of the AcceptPathInfo command are:
Off
It is accepted only when a request is mapped to a real path. In this way, a 404 not found error will be returned for requests that follow a path name after a real file name such as/test/here.html/more.
On
If the preceding path is mapped to an existing file, this request is accepted. If/test/here.html maps a valid file, the request/test/here.html/more in the preceding example is accepted.
Default
The processing method of the request with an additional path name is determined by the corresponding processor. The core processor corresponding to the common text rejects PATH_INFO by default. The processor used for servo scripts, such as cgi-script and isapi-isa, accepts PATH_INFO by default.

The global variable $ _ SERVER ['path _ info'] in PHP is a very useful parameter. this parameter is used by many CMS systems when beautifying their URLs.

For the following URL:
Http://www.test.com/index.php/foo/bar.html? C = index & m = search
We can get $ _ SERVER ['path _ info'] = '/foo/bar.html ', in this case, $ _ SERVER ['query _ string'] = 'C = index & m = search ';
Usually, when we first started writing PHP programs, we would use http://www.test.com/index.php? C = search & m = main. this kind of URL is not only strange, but also unfriendly to search engines. When indexed by many search engines, the content after Query String is ignored. Although google does not ignore Query String, other pages without Query String are given a relatively high PR value.

The following is a simple code for parsing PATH_INFO:

The code is as follows:
If (! Isset ($ _ SERVER ['path _ info']) {
$ Pathinfo = 'default ';
} Else {
$ Pathinfo = explode ('/', $ _ SERVER ['path _ info']);
}
If (is_array ($ pathinfo) AND! Empty ($ pathinfo )){
$ Page = $ pathinfo [1];
} Else {
$ Page = 'A. php ';
}
Require "$ page. php ";
?>


The php file name is followed by a slash "/" and cannot be accessed normally. the not found error is returned.
After the system is damaged, configure the php environment after reinstalling the system. The software used is the same as the previous version.

After the environment is configured, the index. php file can be entered only after a slash is added to the index. php file because all work items are single-entry files. You can access the software before changing the system.

If you want to enter the work project, report not found for unknown reasons. After the test, the php file name and the slash "/" cannot be accessed normally.

Failed to ask many people. Google du Niang failed

Consult a senior php engineer
Apache has the following command: AcceptPathInfo

Add AcceptPathInfo on to the apache configuration file.

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.