下面的Bo-Blog的nginx伪静态设置规则,是乐淘淘番茄红素网的nginx.conf中的代码片段,在此做一记录,以备后用。
server { server_name www.letaotao.net.cn ; rewrite ^(.*) http://letaotao.net.cn$1 permanent; } server { listen 80; server_name letaotao.net.cn; index index.html index.htm index.php; root /home/wwwroot/letaotao; if (!-e $request_filename) { rewrite "^/$" /blog last; rewrite ^/blog/post/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /blog/read.php?entryid=$1&page=$2&part=$3 last; rewrite ^/blog/page/([0-9]+)/([0-9]+)/?$ /blog/index.php?mode=$1&page=$2 last; rewrite ^/blog/starred/([0-9]+)/?([0-9]+)?/?$ /blog/star.php?mode=$1&page=$2 last; rewrite ^/blog/category/jianfei/?$ /blog/index.php?go=category_0 last; rewrite ^/blog/category/fanqiehongsu/?$ /blog/index.php?go=category_1 last; rewrite ^/blog/category/fanqiehongsu/([0-9]+)/([0-9]+)/?$ /blog/index.php?go=category_1&mode=$1&page=$2 last; rewrite ^/blog/category/jianfei/([0-9]+)/([0-9]+)/?$ /blog/index.php?go=category_0&mode=$1&page=$2 last; rewrite ^/blog/category_([0-9]+)/([0-9]+)/([0-9]+)/?$ /blog/index.php?go=category_$1&mode=$2&page=$3 last; rewrite ^/blog/archiver/([0-9]+)/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /blog/index.php?go=archive&cm=$1&cy=$2&mode=$3&page=$4 last; rewrite ^/blog/date/([0-9]+)/([0-9]+)/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /blog/index.php?go=showday_$1-$2-$3&mode=$4&page=$5 last; rewrite ^/blog/user/([0-9]+)/?$ /blog/view.php?go=user_$1 last; rewrite ^/blog/tags/([^/blog/]+)/?([0-9]+)?/?([0-9]+)?/?$ /blog/tag.php?tag=$1&mode=$2&page=$3 last; rewrite ^/blog/component/id/([0-9]+)/?$ /blog/page.php?pageid=$1 last; rewrite ^/blog/component/([^/blog/]+)/?$ /blog/page.php?pagealias=$1 last; #Force redirection for old rules rewrite ^/blog/read\.php/([0-9]+)\.htm$ http://$host/post/$1/ permanent; rewrite ^/blog/post/([0-9]+)\.htm$ http://$host/post/$1/ permanent; rewrite ^/blog/post/([0-9]+)\_([0-9]+)\.htm$ http://$host/post/$1/$2/ permanent; rewrite ^/blog/post/([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/post/$1/$2/$3/ permanent; rewrite ^/blog/index\_([0-9]+)\_([0-9]+)\.htm$ http://$host/page/$1/$2/ permanent; rewrite ^/blog/star\_([0-9]+)\_([0-9]+)\.htm$ http://$host/starred/$1/$2/ permanent; rewrite ^/blog/category\_([0-9]+)\.htm$ http://$host/category/$1/ permanent; rewrite ^/blog/category\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/category/$1/$2/$3/ permanent; rewrite ^/blog/archive\_([0-9]+)\_([0-9]+)\.htm$ http://$host/archiver/$1/$2/ permanent; rewrite ^/blog/archive\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/archiver/$1/$2/$3/$4/ permanent; rewrite ^/blog/showday\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/date/$1/$2/$3/ permanent; rewrite ^/blog/showday\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/date/$1/$2/$3/$4/$5/ permanent; #Filename alias rewrite ^/blog/([a-zA-Z0-9_-]+)/?([0-9]+)?/?([0-9]+)?/?$ /blog/read.php?blogalias=$1&page=$2&part=$3 last; rewrite "/news/s.php/([0-9]+)" /news/s.php?id=$1 break; rewrite "/news/c.php/([0-9]+)" /news/c.php?id=$1 break; rewrite "/news/r.php/([0-9]+)" /news/r.php?id=$1 break; } location ~ .*\.(php|php5)?$ { fastcgi_pass unix:/tmp/php-cgi.sock; #fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; access_log off; } location ~ .*\.(js|css)?$ { expires 15d; } access_log /home/wwwlogs/letaotao.net.cn.log access; }