网络编程 
首页 > 网络编程 > 浏览文章

thinkphp在低版本Nginx 下支持PATHINFO的方法分享

(编辑:jimmy 日期: 2025/4/3 浏览:3 次 )

最近在用thinkphp做一个项目,基本完成后部署到nginx服务器上才发觉nginx是不支持pathinfo的那么我们如何来处理呢。

Nginx环境

在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf(在/usr/local/nginx/conf/nginx.conf或者通过find / | grep nginx.conf来查找位置)中配置转发规则实现:在nginx配置文件中添加:

location / { 
if (!-e $request_filename) {
   rewrite ^(.*)$ /index.php"htmlcode">
location /youdomain/ {
 if (!-e $request_filename){
  rewrite ^/youdomain/(.*)$ /youdomain/index.php"htmlcode">
location /thinkphp/ {
 if (!-e $request_filename){
    rewrite ^/thinkphp/(.*)$ /thinkphp/index.php?s=$1 last;
 }
}

语法:rewrite regex replacement flag  (last     相当于apache里面的[L]标记,表示rewrite。)

上一篇:Centos6.5和Centos7 php环境搭建方法
下一篇:PHP实现数据分页显示的简单实例
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。