thinkphp nginx配置rewrite,地址会多出个.php

thinkphp nginx配置rewrite,地址会多出个.php
,http://localhost:7080/.php?m=…
nginx配置文件
server
{

    listen 80;
    #listen [::]:80;
    server_name localhost 192.168.150.79 doc.mall.com;
    index index.html index.htm index.php default.html default.htm default.php;
    root  /data/www/wwwroot/mall_doc;

include none.conf;

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

location ~ .php {

  • LNMP和Lamp在高并发情况下选择哪个比较好,
  • 天猫和京东的,图片懒加载是 JavaScript写的还是PHP控制的?
  • php中,如果要操作多个表,模型如何写
  • 登陆成功后,右上角显示用户名,cookie里存了,如何读出来放到哪里,求案例
  • linux计划任务如何每分钟执行一条URL
  • ubuntu重新编译php报错make:**[ext/data/php_data.lo] Error 2
  •             fastcgi_pass  unix:/tmp/php-cgi.sock;
                fastcgi_index index.php;
                include fastcgi.conf;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                set $path_info "";
                set $real_script_name $fastcgi_script_name;
                if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                        set $real_script_name $1;
                        set $path_info $2;
                }
                fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
                fastcgi_param SCRIPT_NAME $real_script_name;
                fastcgi_param PATH_INFO $path_info;
        }
    
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
                expires      30d;
        }
    
        location ~ .*\.(js|css)?$
        {
                expires      12h;
        }
    
    access_log  /data/www/wwwlogs/doc.mall.access_log;

    }

    rewrite ^/index.php(.*)$ /index.php?s=$1 last;
    rewrite ^(.*)$ /index.php?s=$1 last;
    rewrite ^/(.*)$ /index.php/$1;
    这三种方式都试过了
    ‘URL_MODEL’ => 2,
    php版本为PHP 7.1.5

    nginx版本为:nginx/1.12.0

    大家有么碰到这种情况?
    php版本在5.6.9上是正常访问

  • GD Library extension not available with this PHP installation.
  • 請問要如何讓搜索引擎根據關鍵字找到我的網頁?
  • 写一套类似畅言多说的程序需要掌握哪些技能
  • 想通过局域网ip 来访问自己电脑的本地项目
  • tp如何让设置session 目录
  • php -S 0.0.0.0 9999 访问静态页面 不成功
  • 2 Solutions collect form web for “thinkphp nginx配置rewrite,地址会多出个.php”

    之前我配置THINKCMF的时候也出现过这个问题

        if(!defined('_PHP_FILE_')) {
            if(IS_CGI) {
                //CGI/FASTCGI模式下
                $_temp  = explode('.php',$_SERVER['PHP_SELF']);
                define('_PHP_FILE_',    rtrim(str_replace($_SERVER['HTTP_HOST'],'',$_temp[0].'.php'),'/'));
            }else {
                define('_PHP_FILE_',    rtrim($_SERVER['SCRIPT_NAME'],'/'));
            }
        }

    后来找到问题是这个$_SERVER[‘SCRIPT_NAME’] 常量中的路径出现问题有2个解决放过
    1.你修改常量中的数据
    2.使用APACHE
    目前就想到这2个方法
    另外可以关注我的博客 PHP程序员学习笔记

        location / {
            try_files $uri $uri/ /index.php$is_args$args;
        }
        
        
        location ~ \.php {
            
             fastcgi_pass   127.0.0.1:9000;
             fastcgi_index  index.php;
             fastcgi_split_path_info ^(.+\.php)(.*)$;     
             fastcgi_param PATH_INFO $fastcgi_path_info;    
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
             include        fastcgi_params;
        }
    .