lnmp集成环境不支持pathinfo模式

[ Nginx ]

在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf中配置转发规则实现:

  location / { // …..省略部分代码
   if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } 

其实内部是转发到了ThinkPHP提供的兼容URL,利用这种方式,可以解决其他不支持PATHINFO的WEB服务器环境。

如果你的应用安装在二级目录,Nginx的伪静态方法设置如下,其中youdomain是所在的目录名称。

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

可查看tp5完全手册配置:https://www.kancloud.cn/manual/thinkphp5/177576
 

猜你喜欢

转载自www.cnblogs.com/betobe/p/11300806.html