server { listen 80; server_name www.funsion.com; root /www/web/funsion; index index.php; # 禁止访问应用目录中的php文件 location ~* ^/application/.+\.php$ { #此目录下的.html要允许访问,因为静态html缓存也是在这个目录下生成 return 403; } location ~* ^/application/Tpl/.+\.html$ { return 403; # 禁止访问模板目录下的html文件 } # 禁止访问ThinkPHP目录中的文件 location ~* ^/ThinkPHP/.+\.(php|tpl|html)$ { return 403; } location / { # ThinkPHP Rewrite, 除以上指定的静态资源外,其它的请求才有必要进行判断 if (!-e $request_filename){ rewrite ^/(.*)$ /index.php/$1 last; } } location ~ \.php($|/){ #配置PHP支持PATH_INFO进行URL重写 set $script $uri; set $path_info ""; if ($uri ~ "^(.+?\.php)(/.+)$") { set $script $1; set $path_info $2; } fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fcgi.conf; fastcgi_param SCRIPT_FILENAME $document_root$script; fastcgi_param SCRIPT_NAME $script; fastcgi_param PATH_INFO $path_info; } location ~* .+\.(gif|jpg|jpeg|png|bmp|swf) { expires 7d; } location ~* .+\.(js|css) { # 缓存一年,文件每次修改后需要在URL中加入时间戳,否则会读取缓存 expires 1y; } }
时间: 2024-10-12 03:34:34