Nginx+Thinkphp部署时,只跳转首页问题

企业实战项目Linux+nginx+php+mysql+redis部署web服务2.0php

因为公司开发使用的是thinkphp框架,以前文档的nginx配置没法很好的支持。html

若是你也遇到这个问题那么将你的nginx.conf修改成以下mysql

注意:如下配置加在 server{}中nginx


location "/"的配置web

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

fastcgi配置redis

注意:若是你的fastcgi配置,location匹配写的是    location ~ \.php$,须要把"$"去掉sql

                location ~ \.php {
                        root html;
                        fastcgi_pass 127.0.0.1:9000;
                        fastcgi_index index.php;                   
                        fastcgi_cache cache_fastcgi;
                        fastcgi_cache_valid 200 302 1h;
                        fastcgi_cache_valid 301 1d;
                        fastcgi_cache_valid any 1m;
                        fastcgi_cache_min_uses 1;
                        fastcgi_cache_use_stale error timeout invalid_header http_500;
                        set $real_script_name $fastcgi_script_name;    
                        if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {    
                            set $real_script_name $1;    
                            set $path_info $2;    
                        }
                        fastcgi_cache_key http://$host$request_uri;
                        fastcgi_split_path_info ^(.+\.php)(.*)$;
                        fastcgi_param PATH_INFO $fastcgi_path_info;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        include fastcgi_params;
                }
相关文章
相关标签/搜索