drupal nginx conf

论坛: 

location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}

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

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

//复写是这个:

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

//如果要支持boost,还有另外一段:

set $boost "";
set $boost_query "_";

if ( $request_method = GET ) {
set $boost G;
}

if ($http_cookie !~ "DRUPAL_UID") {
set $boost "${boost}D";
}

if ($query_string = "") {
set $boost "${boost}Q";
}

if ( -f $document_root/cache/normal/$host$request_uri$boost_query.html ) {
set $boost "${boost}F";
}

if ($boost = GDQF){
rewrite ^.*$ /cache/normal/$host/$request_uri$boost_query.html break;
}

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

# hide protected files
location ~* \.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$ {
deny all;
}

location @rewrite {
rewrite ^/([^/]*)/(.*)(/?)$ /$1/index.php?q=$2&$args;
}

# location ~ ^/sites/.*/files/imagecache/ {
location ~ ^/uploads/imagecache/ {
#..... Stuff here
}

location ~ ^/sites/.*/files/styles/ {
try_files $uri @rewrite;
}

location / {
index index.php index.html;
if (!-f $request_filename) {
rewrite ^(.*)$ /index.php?q=$1 last;
break;
}
if (!-d $request_filename) {
rewrite ^(.*)$ /index.php?q=$1 last;
break;
}
}

location /home/wwwroot/default/d7/ {
index index.php index.html;
if (!-f $request_filename) {
rewrite ^/d7/(.*)$ /d7/index.php?q=$1 last;
break;
}
}

location ~ ^/sites/.*/files/styles/ {
try_files $uri @rewrite;
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}

location ~ \..*/.*\.php$ {
return 403;
}

# No no for private
location ~ ^/sites/.*/private/ {
return 403;
}

location ~ (^|/)\. {
return 403;
}

gzip_static on;

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

# Very rarely should these ever be accessed outside of your lan
location ~* \.(txt|log)$ {
allow 192.168.0.0/16;
deny all;
}

dashan 答复于