nginx 寶塔 路由配置


1--配置php.ini,使php支持pathinfo

 

2、配置nginx.conf

 server
    {
        listen 888;
        server_name 你的域名;
        index index.html index.htm index.php;
        root /www/wwwroot/根目錄;

        #error_page   404   /404.html;
        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }

     	location / {
            if ( -f $request_filename) {
                break;    
            }

            if ( !-e $request_filename) {
                rewrite ^/(.*)$ /index.php/$1 last;
                break;    
            }
        }    

        location ~ \.php {
            set $script $uri;
            set $path_info "";
            if ($uri ~ "^(.+\.php)(/.+)") {
                set $script $1;
                set $path_info $2;    
            }    

            include fastcgi_params;
            fastcgi_index index.php;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param PATH_INFO $path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$script;
            fastcgi_param SCRIPT_NAME $script;
            try_files $uri =404;
        }
        access_log  /www/wwwlogs/access.log;
    }

3、偽靜態

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

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM