WP REST API returning 404’s
-
Hey All,
I’ve been going in circles & circles attempting to fix the issue for a couple of days…Thought it would be best to post here and hope somebody else has experience this issue previously…
I believe that when I curl / access
http://wordpress.local/wp-json/
that I should get something back:me0w@wordpressdev:~$ curl http://wordpress.local/wp-json/ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL was not found on this server.</p> <hr> <address>Apache/2.4.52 (Ubuntu) Server at wordpress.local Port 80</address> </body></html> me0w@wordpressdev:~$ curl http://wordpress.local/wp-json/posts <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL was not found on this server.</p> <hr> <address>Apache/2.4.52 (Ubuntu) Server at wordpress.local Port 80</address> </body></html>
I have a local WordPress development environment:
- PHP v7.4
- WordPress 6.3.1
- Apache2 Web Server
Apache Configuration (/etc/apache2/sites-available/wordpress-local.conf):
<VirtualHost *:80> ServerAdmin webmaster@your_domain DocumentRoot /var/www/html/ ServerName wordpress.local ServerAlias www.wordpress.local ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
.htaccess file:
# BEGIN WordPress # The directives (lines) between "BEGIN WordPress" and "END WordPress" are # dynamically generated, and should only be modified via WordPress filters. # Any changes to the directives between these markers will be overwritten. <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
Mod rewrite is enabled:
me0w@wordpressdev:~$ sudo a2query -m rewrite rewrite (enabled by site administrator) me0w@wordpressdev:~$ sudo a2enmod rewrite Module rewrite already enabled
My site-url & home url in the WordPress DB are as expected:
mysql> SELECT * FROM wp_options WHERE option_name = 'siteurl'; +-----------+-------------+------------------------+----------+ | option_id | option_name | option_value | autoload | +-----------+-------------+------------------------+----------+ | 1 | siteurl | http://wordpress.local | yes | +-----------+-------------+------------------------+----------+ 1 row in set (0.01 sec) mysql> SELECT * FROM wp_options WHERE option_name = 'home'; +-----------+-------------+------------------------+----------+ | option_id | option_name | option_value | autoload | +-----------+-------------+------------------------+----------+ | 2 | home | http://wordpress.local | yes | +-----------+-------------+------------------------+----------+ 1 row in set (0.00 sec)
I also have an entry in my
/etc/hosts
file forwordpress.local
:127.0.0.1 wordpress.local
This is a fresh WordPress installation, so there shouldn’t be any other plugins / themes interfering with the REST API.
I have tried to ‘Flush Rewrites’ by Saving Changes on
Permalink structure
without any changes…It’s currently set toPost name
Any help would be greatly appreciated!
Thanks
Lom
- The topic ‘WP REST API returning 404’s’ is closed to new replies.