1.apache要开启pathinfo模式,需要在
<Directory />
Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
#AcceptPathInfo on #增加这行配置
Require all granted
</Directory>
2.nginx增加pathinfo模式配置:
server {
listen 80;
server_name localhost;
root /data/app;
index index.htm index.html index.php default.php default.html;
#增加下面配置项
location / {
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
###########
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
}
}
关于url的pathinfo模式,要比普通的格式如http://localhost/index.php?a=2&b=3优雅,格式如:http://localhost/index.php/a/2/b/3