server {
listen 80;
server_name domain.com;
charset utf-8;
rewrite_log on; //开启rewritelog,配置时测试用
error_log logs/xxxerror.log notice; //开启rewritelog,配置时测试用
#rewrite 静态文件
rewrite ".*\.(html|js|css|gif|jpg|ico|jpeg|png|bmp|swf|ioc|rar|zip|txt|apk|flv|mid|doc|ppt|pdf|xls|mp3|wma)" /static$uri;
#静态文件访问静态目录
location ^~ /static/ {
expires 30d;
proxy_pass http://httpserver/php/;
}
#配置首页加速
location =/ {
root /usr/local/wordpress/;
fastcgi_pass phpserver;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
#php res api
location ~ ^/wp-json/ {
rewrite ^/wp-json/(.*?)$ /?rest_route=/$1 last;
}
#php 翻页
location ~ ^/page/\d+ {
rewrite ^/page/(\d+) /index.php/?page=$1 last;
}
#目录访问,默认访问php
location / {
#中文url检测
if ($request_filename !~* ^(\w|\d|-|/|\.)+$){
rewrite (.*) /;
}
root /usr/local/wordpress/;
fastcgi_pass phpserver;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
}
网上搜集的url重新规则,比较老了,参考着尝试修改就可以了:
Array
(
[cat/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[cat/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[cat/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2]
[cat/(.+?)/?$] => index.php?category_name=$matches[1]
[post/tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[post/tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[post/tag/([^/]+)/page/?([0-9]{1,})/?$] => index.php?tag=$matches[1]&paged=$matches[2]
[post/tag/([^/]+)/?$] => index.php?tag=$matches[1]
[post/type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?post_format=$matches[1]&feed=$matches[2]
[post/type/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?post_format=$matches[1]&feed=$matches[2]
[post/type/([^/]+)/page/?([0-9]{1,})/?$] => index.php?post_format=$matches[1]&paged=$matches[2]
[post/type/([^/]+)/?$] => index.php?post_format=$matches[1]
[.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$] => index.php?feed=old
[.*wp-app\.php(/.*)?$] => index.php?error=403
[.*wp-register.php$] => index.php?register=true
[feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$matches[1]
[(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$matches[1]
[page/?([0-9]{1,})/?$] => index.php?&paged=$matches[1]
[comments/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$matches[1]&withcomments=1
[comments/(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$matches[1]&withcomments=1
[search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?s=$matches[1]&feed=$matches[2]
[search/(.+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?s=$matches[1]&feed=$matches[2]
[search/(.+)/page/?([0-9]{1,})/?$] => index.php?s=$matches[1]&paged=$matches[2]
[search/(.+)/?$] => index.php?s=$matches[1]
[post/author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?author_name=$matches[1]&feed=$matches[2]
[post/author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?author_name=$matches[1]&feed=$matches[2]
[post/author/([^/]+)/page/?([0-9]{1,})/?$] => index.php?author_name=$matches[1]&paged=$matches[2]
[post/author/([^/]+)/?$] => index.php?author_name=$matches[1]
[post/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]
[post/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]
[post/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]
[post/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]
[post/([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]
[post/([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]
[post/([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]
[post/([0-9]{4})/([0-9]{1,2})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]
[post/([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&feed=$matches[2]
[post/([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&feed=$matches[2]
[post/([0-9]{4})/page/?([0-9]{1,})/?$] => index.php?year=$matches[1]&paged=$matches[2]
[post/([0-9]{4})/?$] => index.php?year=$matches[1]
[post/.?.+?.html/attachment/([^/]+)/?$] => index.php?attachment=$matches[1]
[post/.?.+?.html/attachment/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
[post/.?.+?.html/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
[post/.?.+?.html/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
[post/.?.+?.html/attachment/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
[post/(.?.+?).html/trackback/?$] => index.php?pagename=$matches[1]&tb=1
[post/(.?.+?).html/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?pagename=$matches[1]&feed=$matches[2]
[post/(.?.+?).html/(feed|rdf|rss|rss2|atom)/?$] => index.php?pagename=$matches[1]&feed=$matches[2]
[post/(.?.+?).html/page/?([0-9]{1,})/?$] => index.php?pagename=$matches[1]&paged=$matches[2]
[post/(.?.+?).html/comment-page-([0-9]{1,})/?$] => index.php?pagename=$matches[1]&cpage=$matches[2]
[post/(.?.+?).html(/[0-9]+)?/?$] => index.php?pagename=$matches[1]&page=$matches[2]
[post/[^/]+.html/attachment/([^/]+)/?$] => index.php?attachment=$matches[1]
[post/[^/]+.html/attachment/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
[post/[^/]+.html/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
[post/[^/]+.html/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
[post/[^/]+.html/attachment/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
[post/([^/]+).html/trackback/?$] => index.php?name=$matches[1]&tb=1
[post/([^/]+).html/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?name=$matches[1]&feed=$matches[2]
[post/([^/]+).html/(feed|rdf|rss|rss2|atom)/?$] => index.php?name=$matches[1]&feed=$matches[2]
[post/([^/]+).html/page/?([0-9]{1,})/?$] => index.php?name=$matches[1]&paged=$matches[2]
[post/([^/]+).html/comment-page-([0-9]{1,})/?$] => index.php?name=$matches[1]&cpage=$matches[2]
[post/([^/]+).html(/[0-9]+)?/?$] => index.php?name=$matches[1]&page=$matches[2]
[post/[^/]+.html/([^/]+)/?$] => index.php?attachment=$matches[1]
[post/[^/]+.html/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
[post/[^/]+.html/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
[post/[^/]+.html/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
[post/[^/]+.html/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
)