Wordpress
WordPress is still the world's most popular blog system, more and more by the WordPress built Web site in the use of Nginx Server Software, here to share the WordPress nginx rewrite rules:
server {Listen 80;
server_name www.jb51.net jb51.net;
Access_log/data/logs/nginx/www.jb51.net.access.log main;
Index index.html index.php;
Root/data/site/www.jb51.net;
Location/{try_files $uri $uri//index.php $args;
Add_header Pragma "public";
Expires 12h;
rewrite/wp-admin$ $scheme://$host $uri/permanent; Location ~* ^.+\. (ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|
MID|MIDI|WAV|BMP|RTF) $ {access_log off;
Log_not_found off;
Expires Max;
} location ~ \.php$ {try_files $uri = 404;
Fastcgi_split_path_info ^ (. +\.php) (/.+) $;
#NOTE: should have "cgi.fix_pathinfo = 0;" in php.ini include Fastcgi_params;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
# fastcgi_intercept_errors on;
Fastcgi_pass 127.0.0.1:9000; } location ~. *\.
(gif|jpg|jpeg|png|bmp|swf) $ {expires 24h; Access_log off; } location ~. *\.
(JS|CSS) $ {expires 24h;
Access_log off;
}
You can restart your nginx.
Drupal Nginx Rewrite rules
Drupal is written in PHP language open source Content Management framework, is commonly known as CMS, many people are using Drupal to build their own blog, here also to share the Nginx rewrite rules Drupal:
server {
...
Location/{# This are cool
because no PHP are touched for static content
try_files $uri @rewrite;
}
Location @rewrite {
# Some modules enforce no slash (/) at the "End of" the URL
# Else this rewrite block wouldn ' t b E needed (globalredirect)
rewrite ^/(. *) $/index.php?q=$1;
Location ~ \.php$ {
fastcgi_split_path_info ^ (. +\.php) (/.+) $;
#NOTE: should have "cgi.fix_pathinfo = 0;" In php.ini
include fastcgi_params;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Fastcgi_intercept_errors on;
Fastcgi_pass unix:/tmp/phpfpm.sock;
}
...
}
Restart Nginx