wordpress url rewrite nginx配置

 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]
)
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值