Tricky Rewrite rules.

HonDev Developer developerhondev at gmail.com
Mon Nov 26 13:45:08 MSK 2007


Ok I resend the previous because the email added extra lines:

server {
listen       80;
server_name  yourmublogs.com *.yourmublogs.com;

location / {
root   /home/yourmublogs/public_html;
index  index.html index.htm index.php;
rewrite ^.*/files/(.*) /wp-content/blogs.php?file=$1;

if (!-e $request_filename) {
rewrite ^.+?(/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;

}

if ($query_string !~ ".*s=.*") {
rewrite ^(.*) /wp-content/cache/supercache/$http_host/$1index.html;
}

if ($http_cookie !~ "^.*comment_author_.*$" ) {
rewrite ^(.*) /wp-content/cache/supercache/$http_host/$1index.html;
}

if ($http_cookie !~ "^.*wordpressuser.*$" ) {
rewrite ^(.*) /wp-content/cache/supercache/$http_host/$1index.html;
}

if ($http_cookie !~ "^.*wp-postpass_.*$" ) {
rewrite ^(.*) /wp-content/cache/supercache/$http_host/$1index.html
break;
}


error_page    404  =  @tricky;
}
error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   html;
}

location @tricky {
rewrite ^ /index.php last;
fastcgi_pass   127.0.0.1:8084;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME
/home/yourmublogs/public_html$fastcgi_script_name;
include        /usr/local/nginx/conf/fastcgi_params;
}

location ~ \.php$ {
fastcgi_pass   127.0.0.1:8084;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME
/home/yourmublogs/public_html$fastcgi_script_name;
include        /usr/local/nginx/conf/fastcgi_params;
}
}





More information about the nginx mailing list