WordPress里的所有url rewrite规则清单

WordPress里主要的页面结构分为“文章(post)”、“页面(page)”、分类目录、标签(tag)等,最主要的我们会看到这几种,通常我们关系的wordpress里了url rewrite规则也是跟这几个相关。但其实Wordpress里还有很多我们平时没有主要到的url rewrite规则。

就在上一篇《修改WordPress里页面(page)的固定链接结构的方法》,我注意到了Wordpress里的WP Rewrite这个对象。WP Rewrite是Wordpress里负责url rewrite的对象,这个对象里含有一个数组:$wp_rewrite->rules,它里面存储了所有Wordpress里需要处理的url rewrite规则,下面是这个数组的结构:

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

从这个数组里可以看出,Wordpress里总共大概有60多种rul rewrite规则,这些规则分的很细,每一种对应了一种特征页面。

阅读余下内容
 

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注


京ICP备12002735号