您好,欢迎访问一九零五行业门户网

linux下php安装pathinfo

这篇文章主要介绍了linux下php安装pathinfo,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
linux下php安装pathinfo在nginx.conf配置中,添加 location ~ [^/]\.php(/|$){ fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param path_info $fastcgi_path_info; include fastcgi.conf; include pathinfo.conf; } 在nginx低版本中,是不支持pathinfo的,但是可以通过在nginx.conf中配置转发规则实现。 location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } 一个完整示例,请根据自己服务器加以修改 server { listen 80; server_name www.dolphinphp.com *.dolphinphp.com; root "/home/www/wwwroot/dolphinphp"; location / { index index.html index.htm index.php; #主要是这一段一定要确保存在 if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } #结束 #autoindex on; } location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param script_filename $document_root$fastcgi_script_name; fastcgi_param path_info $fastcgi_path_info; fastcgi_param path_translated $document_root$fastcgi_path_info; include fastcgi_params; } } pathinfo是什么:pathinfo不是nginx的功能,pathinfo是php的功能。 php中有两个pathinfo,一个是环境变量$_server['path_info'];另一个是pathinfo函数,pathinfo() 函数以数组的形式返回文件路径的信息;。 nginx能做的只是对$_server['path_info]值的设置。 php中的pathinfo() pathinfo()函数可以对输入的路径进行判断,以数组的形式返回文件路径的信息,数组包含以下元素。 ● [dirname] 路径的目录 ● [basename] 带后缀 文件名 ● [extension] 文件后缀 ● [filename] 不带后缀文件名(需php5.2以上版本) 例如 [php] <?php print_r(pathinfo("/nginx/test.txt")); ?> [/php] 输出 php 1234567 array( [dirname] => /nginx [basename] => test.txt [extension] => txt [filename] => test) php中的$_server['path_info'] php中的全局变量$_server['path_info'],path_info是一个cgi 1.1的标准,经常用来做为传参载体。 被很多系统用来优化url路径格式,最著名的如thinkphp框架。 对于下面这个网址: http://www.test.cn/index.php/test/my.html?c=index&m=search 我们可以得到 $_server['path_info'] = ‘/test/my.html’,而此时 $_server['query_string'] = 'c=index&m=search'; 如果不借助高级方法,php中http://www.test.com/index.php?type=search 这样的url很常见,大多数人可能会觉得不太美观而且对于搜索引擎也是非常不友好的(实际上有没有影响未知),因为现在的搜索引擎已经很智能了,可以收入带参数的后缀网页,不过大家出于整洁的考虑还是想希望能够重写url
相关推荐:
windows7 php安装oci扩展
windows下为php安装redis扩展
以上就是linux下php安装pathinfo的详细内容。
其它类似信息

推荐信息