所有的框架处理业务请求时,都会处理URL的路径部分,分配到指定的代码中去处理。
实现这一功能的关键就是获取$_SERVER全局变量中对于URL部分的数据
当请求的路径为http://test.com/article?id=1http://test.com/article/update?id=1
支持以上url模式,不需要配置传递PATH_INFO变量,也不需要配置伪静态去除index.php最简单的nginx配置如下:
server {
listen 80;
server_name test.com;
access_log /var/log/nginx/test.com.access.log main;
root /home/test;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ .php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
此配置有几个重点要关注:
1.try_fil