thinkphp 伪静态 nginx 规则怎么设置

大神帮我问一下,thinkphp 伪静态 nginx 规则怎么设置
最新回答
ツ蓝翔老司机

2024-05-04 03:05:31

  • 关于nginx的伪静态设置(案例)

server {

listen 80;

server_name localhost;

index index.html index.htm index.php;

root /alidata/www/;


location / {

if (!-e $request_filename){

rewrite ^/(.*)$ /index.php?s=/$1 last;

}

}


location ~ .*\.(php|php5)?$

{

#fastcgi_pass unix:/tmp/php-cgi.sock;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi.conf;


# 以下是为了让Nginx支持PATH_INFO

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;


fastcgi_connect_timeout 120;

fastcgi_send_timeout 120;

fastcgi_read_timeout 120;

fastcgi_buffers 8 128K;

fastcgi_buffer_size 128K;


}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

location ~ .*\.(js|css)?$

{

expires 1h;

}

#伪静态规则

access_log /alidata/log/nginx/access/default.log;

}