Encountering a 404 error when accessing WordPress REST API endpoints

I have been utilizing the WordPress REST API for some time without issues when working locally on XAMPP. Now that I have transferred my site to an EC2 server, I’m facing a problem with the REST API.

Whenever I attempt to access any endpoint, I receive a 404 error that states:

The requested URL /wordpress/wp-json/ was not found on this server

I’ve enabled pretty permalinks, and they function correctly when I browse to individual posts, like this one: http://.../wordpress/my-sample-post/.

Here’s my current setup:

  • WordPress version 4.4.1 (not a multisite)
  • WP REST API plugin version 2.0-beta9
  • Apache version 2.2.22
  • Operating on Ubuntu version 12.04.5

I would greatly appreciate any help, as I’ve already searched Stack Overflow and WordPress support for hours without luck. Thank you!

Same thing happened when I moved from local dev. Add this to ur .htaccess file in the WordPress root: RewriteRule ^wp-json/(.*) /wordpress/wp-json/$1 [R=301,L] - just replace /wordpress/ with whatever ur actual subdirectory is. Also check that ur site URL settings in WP admin match ur new server.

Had the exact same issue when I migrated my WordPress site. It’s usually an Apache config problem with mod_rewrite settings. Since your post permalinks work fine, something’s blocking access to the wp-json endpoints. Check that AllowOverride is set to All in your Apache config for the WordPress directory. Also run apache2ctl -M | grep rewrite to make sure mod_rewrite is actually enabled. Fixed it for me after reloading Apache.

Same thing happened to me after a server migration. Your WordPress is probably in a subdirectory - that messes up the REST API paths. Try the full path: http://yourdomain.com/wordpress/wp-json/wp/v2/posts instead of just /wp-json/. Check your WordPress Address and Site Address URLs in General Settings too - they’ve got to match your server setup exactly. Still broken? Switch to default permalinks, test the API, then turn pretty permalinks back on.

Had this exact problem during my WordPress migration to AWS. Apache wasn’t handling the wp-json rewrite rules properly in the subdirectory setup. Since permalinks work for posts but not API endpoints, your WordPress rewrite rules are probably clashing with Apache’s directory config. Add DirectoryIndex index.php to your .htaccess and make sure DocumentRoot points to your WordPress install. Double-check that wp-config.php has the right WP_HOME and WP_SITEURL constants for your new server. Took me days to figure out my Apache VirtualHost was overriding WordPress rewrite rules just for API paths.

Been there with EC2 migrations. This 404 mess is classic - manual server configs hate WordPress.

Skip wrestling with Apache settings and htaccess files. I handle all WordPress API stuff through automation. When you’re migrating servers and endpoints break, you need something that routes requests properly no matter what your setup looks like.

I built a workflow that catches API calls and routes them through a reliable proxy. It handles subdirectory paths automatically, manages auth, and does error handling when endpoints die. No more digging through Apache logs or tweaking rewrite rules every server move.

The workflow monitors your endpoints and falls back to direct database queries when REST API craps out. Logs everything so you can see exactly what’s breaking and when.

Saved me tons of time on similar EC2 WordPress setups. Way better than manual server debugging.