When learning zfdemo, I mentioned setting the AcceptPathInfo command.
Sometimes when we are doing virtual staticization or making the path look beautiful, we may see http://www.example A URL address like .com/index.php/html1 is actually accessed from the index.php file in the root directory, and /html1 is passed to the script as the PATH_INFO environment variable. For apache, whether the above address can run correctly depends on the configuration of the AcceptPathInfo directive
AcceptPathInfo directive
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
Override item FileInfo
State core (C)
Module core
Compatibility is only available in Apache 2.0.30 and later
This directive determines whether to accept requests that follow the actual file name (or a non-existent file in the actual directory) followed by redundant pathname information . This extra pathname information can be passed to the script as the PATH_INFO environment variable.
For example, assuming that the directory pointed to by /test/ contains only one file: here.html, then requests for /test/here.html/more and /test/nothere.html/more will be The PATH_INFO environment variable is set to "/more".
The value range of the AcceptPathInfo directive:
Off
A request will only be accepted if it is mapped to a real path. Thus, a request that follows the real filename followed by a pathname like /test/here.html/more above will return a "404 NOT FOUND" error.
On
As long as the leading path can be mapped to a real existing file, the request can be accepted. In this way, as long as the above /test/here.html can be mapped to a valid file, the request for /test/here.html/more will be received.
Default
Whether a request with redundant pathname information is accepted is determined by its corresponding processor. Core processors that handle normal text reject PATH_INFO by default. Processors used for server scripts, such as cgi-script and isapi-isa, will accept PATH_INFO by default.
The primary purpose of the AcceptPathInfo directive is to allow you to override the processor's default setting of whether to accept PATH_INFO. This coverage is necessary. For example, when you use a filter like INCLUDES to generate content based on PATH_INFO. The core processor usually rejects such requests, and you can enable such scripts with the following configuration:
Options +Includes
SetOutputFilter INCLUDES
AcceptPathInfo On
The default in apache 2.0 and above is that there is no acceptpathinfo
Acceptpathinfo has been removed from APACH2.0.30 and above servers; if necessary, you need to add the AcceptPathInfo On entry in http.conf. That is, the original
Options FollowSymLinks includes
AllowOverride None
is changed to
Options FollowSymLinks includes
AllowOverride None
AcceptPathInfo On
This command determines whether to accept Contains path information appended to a certain file (or a non-existent file in an existing directory). This path information will appear in the script as the PATH_INFO environment variable.
For example, assume that the directory pointed to by /test/ contains only one file: here.html. Then requests for /test/here.html/more and /test/nothere.html/more will get PATH_INFO variables like /more. The three parameters of the
AcceptPathInfo directive are:
off
A request will only be accepted if it is mapped to a real path. Thus, a request such as /test/here.html/more above with a pathname following the real filename will return a 404 NOT FOUND error.
on
If the preceding path maps to a real file, the request will be accepted. If /test/here.html maps to a valid file, the request for /test/here.html/more in the above example will be accepted.
default
The processing method of requests with additional path names is determined by its corresponding processor. Core processors that handle normal text reject PATH_INFO by default. Processors used for server scripts, such as cgi-script and isapi-isa, will accept PATH_INFO by default.
The global variable $_SERVER['PATH_INFO'] in PHP is a very useful parameter. Many CMS systems use this parameter 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', and at this time $_SERVER['QUERY_STRING'] = 'c=index&m=search';
Usually, when we first start writing PHP programs, we will use things like: http A URL like ://www.test.com/index.php?c=search&m=main not only looks very strange, but is also very unfriendly to search engines. Many search engines will ignore the content after the Query String when indexing. Although Google will not ignore the Query String, it will give a relatively high PR value to other pages that do not contain the Query String.
The following is a very simple code to parse PATH_INFO: