Tricky Rewrite rules.

HonDev Developer developerhondev at gmail.com
Thu Apr 24 11:26:27 MSD 2008


Here is an updated config to test:

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

location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
root /home/yourmublogs/public_html;
rewrite ^/.*(/wp-admin/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$
$1 last;
rewrite ^/.*(/wp-includes/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$
$1 last;
rewrite ^/.*(/wp-content/themes/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$
$1 last;
rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$
/wp-content/blogs.php?file=$1 last;
expires 10d;
break;
}

location / {
root   /home/yourmublogs/public_html;
index  index.html index.htm index.php;

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

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

error_page    404  =  @tricky;
}

location @tricky {
rewrite ^ /index.php last;
rewrite ^/.*(/wp-login.php)$ $1;
rewrite ^/.*(/wp-admin/.*\.php)$ $1;
rewrite ^/.*(/wp-includes/.*\.php)$ $1;
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;
}

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

server {
server_name www.yourmublogs.com;
rewrite ^/(.*) http://yourmublogs.com/$1 permanent;
}





More information about the nginx mailing list