server { listen 2223; server_name manage; access_log /data/wwwlogs/access_manage.log combined; root /data/wwwroot/webroot/manage/public; index index.html index.htm admin.php;#默认后台admin.php location / { if (!-e $request_filename) { rewrite ^(.*)$ /admin.php$1 last; #隐藏后台入口文件admin.php break; } } location ~ ^(.+.php)(.*)$ { # try_files $uri =404; fastcgi_pass unix:/dev/shm/php-cgi.sock; #注意:不同系统,路由不一样 fastcgi_index index.php; include fastcgi_params; fastcgi_split_path_info ^(.+.php)(/?.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; # 强制将某些非法地址交给 index.php 处理 set $new_fastcgi_script_name $fastcgi_script_name; if (!-e $document_root$fastcgi_script_name) { set $new_fastcgi_script_name "/index.php"; } fastcgi_param SCRIPT_FILENAME $document_root$new_fastcgi_script_name; fastcgi_param SCRIPT_NAME $new_fastcgi_script_name; } location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ { if (!-e $request_filename) { rewrite ^/(uploads/.*)$ /pic.php?$1 last; } expires 30d; } location ~ .*.(js|css)?$ { expires 7d; # 缓存7天 } location ~ /.ht { deny all; } }