nginx下wordpress的rewrite

server {
    listen 80;

    root /usr/share/nginx/wordpress;
    index index.php index.html index.htm;

    server_name idudu.xyz;

    location / {
        try_files $uri $uri/ /index.html;
        if (-f $request_filename/index.html){
            rewrite (.*) $1/index.html break;
        }
        if (-f $request_filename/index.php){
            rewrite (.*) $1/index.php;
        }
        if (!-f $request_filename){
            rewrite (.*) /index.php;
        }
    }


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

    # pass the PHP scripts to FastCGI server listening on the php-fpm socket
    location ~ .php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

    }

}

 

posted @ 2015-03-10 22:43  MagicLetters  阅读(397)  评论(0)    收藏  举报