WP 5.2.4
/wp-json/wp/v2/
给出404错误。
我更新了permalinks,有一个工作。在Apache上使用htaccess,并且不使用“普通permalinks”,但这仍然不起作用。我的Apache及其配置看起来不错,除了/wp-json
.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
如何修复这个令人沮丧的WP bug?当人们
struggle with this everyday?
我的WP路线如下(修剪):
array (
\'^wc-auth/v([1]{1})/(.*)?\' => \'index.php?wc-auth-version=$matches[1]&wc-auth-route=$matches[2]\',
\'^wc-api/v([1-3]{1})/?$\' => \'index.php?wc-api-version=$matches[1]&wc-api-route=/\',
\'^wc-api/v([1-3]{1})(.*)?\' => \'index.php?wc-api-version=$matches[1]&wc-api-route=$matches[2]\',
\'sitemap_index\\\\.xml$\' => \'index.php?sitemap=1\',
\'([^/]+?)-sitemap([0-9]+)?\\\\.xml$\' => \'index.php?sitemap=$matches[1]&sitemap_n=$matches[2]\',
\'([a-z]+)?-?sitemap\\\\.xsl$\' => \'index.php?yoast-sitemap-xsl=$matches[1]\',
\'shop-4/?$\' => \'index.php?post_type=product\',
\'shop-4/feed/(feed|rdf|rss|rss2|atom)/?$\' => \'index.php?post_type=product&feed=$matches[1]\',
\'shop-4/(feed|rdf|rss|rss2|atom)/?$\' => \'index.php?post_type=product&feed=$matches[1]\',
\'shop-4/page/([0-9]{1,})/?$\' => \'index.php?post_type=product&paged=$matches[1]\',
\'^wp-json/?$\' => \'index.php?rest_route=/\',
\'^wp-json/(.*)?\' => \'index.php?rest_route=/$matches[1]\',
....
如您所见,wp json规则应该与URL匹配,如
/wp-json/wp/v2/posts/6307
我已经检查了哪些rest路由可用(使用插件“rest管理器”,又好又干净):
/wp/v2/posts/
/wp/v2/posts/(?P<id>[\\d]+)
当我点击URL时:
/index.php?rest_route=wp/v2/posts/6307
/index.php?rest_route=/wp/v2/posts/6307
/index.php?rest_route=wp/v2/posts/
/index.php?rest_route=/wp/v2/posts/
我对他们都很满意:
(404)
{"code":"rest_no_route","message":"No route was found matching the URL and request method","data":{"status":404}}
他们说端点列表可以通过
GET /wp-json/
但这一页也给出了404。
路线的行为完全相同,我知道他们使用的是GET动词:
404 /wp-json/wp/v2/block-renderer/woocommerce/