代碼加入到server內,以下 :php
location ~* ^/(uploads|templets)/.*.(php|php5)$ { deny all; }
完整站點配置以下:css
server { listen 80; root /www/web/yujianlong_com/public_html; server_name yujianlong.com www.yujianlong.com; index index.html index.php index.htm; fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/"; error_page 400 /errpage/400.html; error_page 403 /errpage/403.html; error_page 404 /errpage/404.html; error_page 503 /errpage/503.html; location ~* ^/(uploads|templets)/.*.(php|php5)$ { deny all; } location ~ \.php(.*)$ { fastcgi_pass unix:/tmp/php-55-cgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $DOCUMENT_ROOT$fastcgi_script_name; fastcgi_param PATH_INFO $2; include fcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 1d; } location ~ .*\.(js|css|html|htm)?$ { expires 12h; } location ~ /\.ht { deny all; } location / { try_files $uri $uri/ /?$args; } }