普通站点规则:
- # WordPress single site rules.
- # Designed to be included in any server {} block.
- # Upstream to abstract backend connection(s) for php
- upstream php {
- server unix:/tmp/php-cgi.socket;
- server 127.0.0.1:9000;
- }
- server {
- ## Your website name goes here.
- server_name domain.tld;
- ## Your only path reference.
- root /var/www/wordpress;
- ## This should be in your http block and if it is, it's not needed here.
- index index.php;
- location = /favicon.ico {
- log_not_found off;
- access_log off;
- }
- location = /robots.txt {
- allow all;
- log_not_found off;
- access_log off;
- }
- location / {
- # This is cool because no php is touched for static content.
- # include the "?$args" part so non-default permalinks doesn't break when using query string
- try_files $uri $uri/ /index.php?$args;
- }
- location ~ \.php$ {
- #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
- include fastcgi.conf;
- fastcgi_intercept_errors on;
- fastcgi_pass php;
- fastcgi_buffers 16 16k;
- fastcgi_buffer_size 32k;
- }
- location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
- expires max;
- log_not_found off;
- }
- }
多站点:
- # WordPress multisite subdirectory rules.
- # Designed to be included in any server {} block.
- map $uri $blogname{
- ~^(?P<blogpath>/[^/]+/)files/(.*) $blogpath ;
- }
- map $blogname $blogid{
- default -999;
- #Ref: http://wordpress.org/extend/plugins/nginx-helper/
- #include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ;
- }
- server {
- server_name example.com ;
- root /var/www/example.com/htdocs;
- index index.php;
- location ~ ^(/[^/]+/)?files/(.+) {
- try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
- access_log off; log_not_found off; expires max;
- }
- #avoid php readfile()
- location ^~ /blogs.dir {
- internal;
- alias /var/www/example.com/htdocs/wp-content/blogs.dir ;
- access_log off; log_not_found off; expires max;
- }
- if (!-e $request_filename) {
- rewrite /wp-admin$ $scheme://$host$uri/ permanent;
- rewrite ^(/[^/]+)?(/wp-.*) $2 last;
- rewrite ^(/[^/]+)?(/.*\.php) $2 last;
- }
- location / {
- try_files $uri $uri/ /index.php?$args ;
- }
- location ~ \.php$ {
- try_files $uri =404;
- include fastcgi_params;
- fastcgi_pass php;
- }
- #add some rules for static content expiry-headers here
- }
本文来源:www.365-588.com原创
如果您喜欢本文请分享给您的好友,谢谢!如想浏览更多更好的建站程序内容,请登录:http://www.tootnn.com/edu/website/6/index.html