WP 5.2.4
/wp-json/wp/v2/
Gives 404 error.
I updated permalinks,have a working .htaccess on Apache and not using "plain permalinks" and still this thing don't work. My Apache and its configuration look fine and everything works except for /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>
How to fix this frustrating WP bug? Why doesn't Wordpress improve this, when people struggle with this everyday?
My WP routes look like this (trimmed):
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]',
....
As you can see, the wp-json rules should do as it matches an URL like
/wp-json/wp/v2/posts/6307
I have checked which rest routes are available (using the plugin "Rest Manager", nice and clean):
/wp/v2/posts/
/wp/v2/posts/(?P<id>[\d]+)
When I hit the URLs:
/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/
I get with all of them:
(404)
{"code":"rest_no_route","message":"No route was found matching the URL and request method","data":{"status":404}}
They say a list of endpoints is available through GET /wp-json/
but this page also gives 404.
Behaviour is exactly the same for routes I know they are using GET verbs:
404 /wp-json/wp/v2/block-renderer/woocommerce/