Wordpress rewrite_rules顺序错误

时间:2015-01-24 14:29:45

标签: php wordpress rewrite

使用迁移数据库导出后,我的重写规则不是很好,我无法在数据库中修复它,因为当我重新生成它们时,它会再次发生。

我不知道它是否与插件有关。

我称之为规则的是我的自定义帖子类型添加的规则。

因此,规则应首先从我的规则开始(来自自定义帖子类型),但它始于

.?.+?/attachment/([^/]+)/?$ => index.php?attachment=$matches[1]

这个规则及其后面的规则(我在其他wordpress数据库中检查过)应该接近数组的末尾。

我的问题是,在这个之后有一个规则会破坏我网站中的每一页(因为它太通用并且捕获所有内容),就是这个:

"(.?.+?)(/[0-9]+)?/?$ => index.php?pagename=$matches[1]&page=$matches[2]"

我已经调试过但我无法解决它。

这是订单:

".?.+?/attachment/([^/]+)/?$ => index.php?attachment=$matches[1]"
".?.+?/attachment/([^/]+)/trackback/?$ => index.php?attachment=$matches[1]&tb=1"
".?.+?/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ => index.php?attachment=$matches[1]&feed=$matches[2]"
".?.+?/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ => index.php?attachment=$matches[1]&feed=$matches[2]"
".?.+?/attachment/([^/]+)/comment-page-([0-9]{1,})/?$ => index.php?attachment=$matches[1]&cpage=$matches[2]"
"(.?.+?)/trackback/?$ => index.php?pagename=$matches[1]&tb=1"
"(.?.+?)/feed/(feed|rdf|rss|rss2|atom)/?$ => index.php?pagename=$matches[1]&feed=$matches[2]"
"(.?.+?)/(feed|rdf|rss|rss2|atom)/?$ => index.php?pagename=$matches[1]&feed=$matches[2]"
"(.?.+?)/page/?([0-9]{1,})/?$ => index.php?pagename=$matches[1]&paged=$matches[2]"
"(.?.+?)/comment-page-([0-9]{1,})/?$ => index.php?pagename=$matches[1]&cpage=$matches[2]"
"(.?.+?)/wc-api(/(.*))?/?$ => index.php?pagename=$matches[1]&wc-api=$matches[3]"
"(.?.+?)/order-pay(/(.*))?/?$ => index.php?pagename=$matches[1]&order-pay=$matches[3]"
"(.?.+?)/order-received(/(.*))?/?$ => index.php?pagename=$matches[1]&order-received=$matches[3]"
"(.?.+?)/view-order(/(.*))?/?$ => index.php?pagename=$matches[1]&view-order=$matches[3]"
"(.?.+?)/edit-account(/(.*))?/?$ => index.php?pagename=$matches[1]&edit-account=$matches[3]"
"(.?.+?)/edit-address(/(.*))?/?$ => index.php?pagename=$matches[1]&edit-address=$matches[3]"
"(.?.+?)/lost-password(/(.*))?/?$ => index.php?pagename=$matches[1]&lost-password=$matches[3]"
"(.?.+?)/customer-logout(/(.*))?/?$ => index.php?pagename=$matches[1]&customer-logout=$matches[3]"
"(.?.+?)/add-payment-method(/(.*))?/?$ => index.php?pagename=$matches[1]&add-payment-method=$matches[3]"
".?.+?/([^/]+)/wc-api(/(.*))?/?$ => index.php?attachment=$matches[1]&wc-api=$matches[3]"
".?.+?/attachment/([^/]+)/wc-api(/(.*))?/?$ => index.php?attachment=$matches[1]&wc-api=$matches[3]"
"(.?.+?)(/[0-9]+)?/?$ => index.php?pagename=$matches[1]&page=$matches[2]"

// my rules ...

".*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]"
"comment-page-([0-9]{1,})/?$ => index.php?&page_id=20&cpage=$matches[1]"
"wc-api(/(.*))?/?$ => index.php?&wc-api=$matches[2]"
"order-pay(/(.*))?/?$ => index.php?&order-pay=$matches[2]"
"order-received(/(.*))?/?$ => index.php?&order-received=$matches[2]"
"view-order(/(.*))?/?$ => index.php?&view-order=$matches[2]"
"edit-account(/(.*))?/?$ => index.php?&edit-account=$matches[2]"
"edit-address(/(.*))?/?$ => index.php?&edit-address=$matches[2]"
"lost-password(/(.*))?/?$ => index.php?&lost-password=$matches[2]"
"customer-logout(/(.*))?/?$ => index.php?&customer-logout=$matches[2]"
"add-payment-method(/(.*))?/?$ => index.php?&add-payment-method=$matches[2]"
"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"
"comments/wc-api(/(.*))?/?$ => index.php?&wc-api=$matches[2]"
"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/(.+)/wc-api(/(.*))?/?$ => index.php?s=$matches[1]&wc-api=$matches[3]"
"search/(.+)/?$ => index.php?s=$matches[1]"
"author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ => index.php?author_name=$matches[1]&feed=$matches[2]"
"author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ => index.php?author_name=$matches[1]&feed=$matches[2]"
"author/([^/]+)/page/?([0-9]{1,})/?$ => index.php?author_name=$matches[1]&paged=$matches[2]"
"author/([^/]+)/wc-api(/(.*))?/?$ => index.php?author_name=$matches[1]&wc-api=$matches[3]"
"author/([^/]+)/?$ => index.php?author_name=$matches[1]"
"([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]"
"([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]"
"([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]"
"([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/wc-api(/(.*))?/?$ => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&wc-api=$matches[5]"
"([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]"
"([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$ => index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]"
"([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$ => index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]"
"([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$ => index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]"
"([0-9]{4})/([0-9]{1,2})/wc-api(/(.*))?/?$ => index.php?year=$matches[1]&monthnum=$matches[2]&wc-api=$matches[4]"
"([0-9]{4})/([0-9]{1,2})/?$ => index.php?year=$matches[1]&monthnum=$matches[2]"
"([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$ => index.php?year=$matches[1]&feed=$matches[2]"
"([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$ => index.php?year=$matches[1]&feed=$matches[2]"
"([0-9]{4})/page/?([0-9]{1,})/?$ => index.php?year=$matches[1]&paged=$matches[2]"
"([0-9]{4})/wc-api(/(.*))?/?$ => index.php?year=$matches[1]&wc-api=$matches[3]"
"([0-9]{4})/?$ => index.php?year=$matches[1]"
"[^/]+/attachment/([^/]+)/?$ => index.php?attachment=$matches[1]"
"[^/]+/attachment/([^/]+)/trackback/?$ => index.php?attachment=$matches[1]&tb=1"
"[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ => index.php?attachment=$matches[1]&feed=$matches[2]"
"[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ => index.php?attachment=$matches[1]&feed=$matches[2]"
"[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$ => index.php?attachment=$matches[1]&cpage=$matches[2]"
"([^/]+)/trackback/?$ => index.php?name=$matches[1]&tb=1"
"([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ => index.php?name=$matches[1]&feed=$matches[2]"
"([^/]+)/(feed|rdf|rss|rss2|atom)/?$ => index.php?name=$matches[1]&feed=$matches[2]"
"([^/]+)/page/?([0-9]{1,})/?$ => index.php?name=$matches[1]&paged=$matches[2]"
"([^/]+)/comment-page-([0-9]{1,})/?$ => index.php?name=$matches[1]&cpage=$matches[2]"
"([^/]+)/wc-api(/(.*))?/?$ => index.php?name=$matches[1]&wc-api=$matches[3]"
"[^/]+/([^/]+)/wc-api(/(.*))?/?$ => index.php?attachment=$matches[1]&wc-api=$matches[3]"
"[^/]+/attachment/([^/]+)/wc-api(/(.*))?/?$ => index.php?attachment=$matches[1]&wc-api=$matches[3]"
"([^/]+)(/[0-9]+)?/?$ => index.php?name=$matches[1]&page=$matches[2]"
"[^/]+/([^/]+)/?$ => index.php?attachment=$matches[1]"
"[^/]+/([^/]+)/trackback/?$ => index.php?attachment=$matches[1]&tb=1"
"[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ => index.php?attachment=$matches[1]&feed=$matches[2]"
"[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ => index.php?attachment=$matches[1]&feed=$matches[2]"
"[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$ => index.php?attachment=$matches[1]&cpage=$matches[2]"

我用一些array_splice修复了问题(暂时),但我相信这个修复可能会在未来中突破

我想知道为什么这一代错了

非常感谢

0 个答案:

没有答案