Conclusion test environment:
Ubuntu Server 14.04
PHP Version 5.5.9-1ubuntu4
Apache/2.4.7 (Ubuntu)
PATH_INFO is a parameter in the SERVER Status. You can view the content through $ _ SERVER ['path _ info. In addition to PATH_INFO, the $ _ SERVER array also contains a large amount of data. For example, REQUEST_URI contains more information.
There is also a confusing concept: pathinfo refers to a function of PHP4 (4.0.3) to return the path information of a file.
Apache supports the PATH_INFO function by default. Many tutorials on the Internet do not need to modify apache configuration files, but modify php configuration files. In fact, no files need to be modified, you can use either of the following methods to verify the PATH_INFO function.
Method 1: Native Code Testing
On a brand new system, such as creating a Ubuntu 14.04 Server virtual machine, only the OpenSSH and LAMP software packages are installed.
Create a test file pathinfo. php in the directory/var/www/html of Apache. The content is
<? Php
Echo $ _ SERVER ['path _ info'];
?>
Assume that the IP address of the VM is 192.168.1.106. Access http: // 192.168.1.106/pathinfo. php and a blank page is displayed. Because this URL does not contain the PATH_INFO information.
Test http: // 192.168.1.106/pathinfo. php/year/2014/by changing the URL. The/year/2014/page displays the PATH_INFO information.
Method 2: Use ThinkPHP to test
Many PHP frameworks need to obtain the value of PATH_INFO. Taking ThinkPHP as an example, the basic steps are as follows:
Download the latest ThinkPHP file to the/var/www/html/directory, decompress the file, and modify the file permission to www-data.
Access URL http: // 192.168.1.106/index. php, the file list under the Application is automatically generated
Edit the file Application/Home/Controller/IndexController. class. php. The content is
<? Php
Namespace HomeController;
Use ThinkController;
Class IndexController extends Controller {
Public function index (){
$ This-> show ('Hi, all', 'utf-8 ');
}
Public function test (){
$ This-> show ('test ');
}
}
When you access http: // 192.168.1.106/index. php basically accesses http: // 192.168.1.106/index. php/Home/Index/index. If you can access it later, it indicates that PATH_INFO is normal.
If an exception exists, ThinkPHP may report that the module/controller cannot be loaded or the operation is illegal. You can access the test method to verify the error.
Enter the URL http: // 192.168.1.106/index. php/Home/Index/test for testing. The test is displayed on the page.
Supplement: Support for enabling PathInfo mode in Apache2.2.22
Add
<Files *. php>
AcceptPathInfo On
</Files>
In this way, Apache supports PathInfo for php files.
As a result, Xiao Yu tried again with hope. Unfortunately, he still failed.
I think this PathInfo is related to the URL. Is it because the Apache server has not enabled the mod_rewrite module? So I found the following in the Apache configuration file (httpd. conf file in the conf folder of the Apache installation directory:
# LoadModule rewrite_module modules/mod_rewrite.so
Remove the previous # and change it:
LoadModule rewrite_module modules/mod_rewrite.so
Save. After restarting the server, the project can finally be accessed in PathInfo mode.