阅读 266

nginx配置支持Thinkphp3.2

apache对thinkphp支持很好,只需要thinkphp目录下放置.htaccess文件即可,例如:


  Options +FollowSymlinks
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]


但是换到nginx会各种文件404,打不开等等
如下为nginx配置文件,直接复制粘粘修改
然后如果需要模式2(隐藏index.php) 在thinkphp的配置文件config.php中添加 ‘URL_MODEL‘ => ‘2‘

    server {
        listen       443 ssl;
        server_name  www.a.com;
        root   /home/www.a.com;
        index  index.html index.htm index.php;

        ssl_certificate      /tmp/server.crt;
        ssl_certificate_key  /tmp/server.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;


        location / {
            if (!-e $request_filename) {
                #如果是二级目录,xxx表示上层目录名
                #rewrite ^/xxx/(.*)$ /xxx/index.php?s=$1 last;
                rewrite ^(.*)$ /index.php?s=$1 last;
                break;
            }


        }

        location ~ \.php(.*)$ {
            root           /home/go.jinianri.com;
            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;
        }

    }


原文:https://www.cnblogs.com/shipment/p/14750181.html

文章分类
代码人生
文章标签
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐