Wordpress JsonAPI - /wp-json/ was not found on this server
Asked Answered
A

10

53

I am using the following plugin Json Rest API.

To test the plugin the documentation states that I should just use:

$ curl -i http://testpress-maxximus.rhcloud.com/wp-json/
HTTP/1.1 404 Not Found
Date: Sat, 24 May 2014 07:01:21 GMT
Server: Apache/2.2.15 (Red Hat)
Content-Length: 303
Content-Type: text/html; charset=iso-8859-1

<!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 /wp-json/ was not found on this server.</p>
<hr>
<address>Apache/2.2.15 (Red Hat) Server at testpress-maxximus.rhcloud.com Port 8
0</address>
</body></html>

As you can see nothing is found by the URL. Any recommendations if there is a problem with the API or wordpress?

I appreciate your reply

Accumbent answered 24/5, 2014 at 7:4 Comment(1)
Do you have pretty permalinks enabled?Cornerwise
A
77

The current version of REST api for sites with pretty permalinks not enabled, the url

    yoursite.com/?rest_route=/ 

will work .

Alguire answered 30/1, 2017 at 9:42 Comment(3)
@Foad it needs preety permalinks enabledBenzene
@DrDeo Have a look #18353182Alguire
Its probably worth noting that this url will work whether permilinks are enabled or not, so if you are unable to know, then this is the safer option to useFronton
J
44

The WordPress JSON API depends on pretty permalinks, make sure you have them enabled for the site.

Jerroldjerroll answered 30/11, 2014 at 18:50 Comment(3)
aka - go to Settings > Permalinks and change the setting to "Post name" to get it to work for you. I would be cautious about doing this if you already have a live site as it will modify a lot of your urls.Globefish
But see the comment by @Mohammad AlBanna https://mcmap.net/q/336842/-wordpress-jsonapi-wp-json-was-not-found-on-this-serverConfucius
I had permalinks set to post-name already but was seeing the error. So I switched to a different setting and then switched back to post-name which fixed it for meLatif
S
34

In my case, I got this error after installing/configuring apache2 on my local linux machine. I finally found the error to be cause by the rewrite module not being enabled which I fixed using,

sudo a2enmod rewrite

as well as ensuring that my apache2.conf file (located in the folder /etc/apache2) has its<Directory> directive 'AllowOverride' set to all rather than none, from

<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>

to

<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>

then I restarted apache2 service and the problem was resolved.

Sorption answered 9/10, 2018 at 10:56 Comment(3)
how to do this if you have Bluehost as server?Reefer
you'll need to reach out to your support to get the apache configuration files. Bluehost does not make it easy for you to access these files.Sorption
Thank You! It works!Aspinwall
G
32

I have faced this issue several times . The solution is this :

Login into your Wordpress site: example.com/wp-admin

  1. Then click on settings

  2. Then click on permalinks

  3. Then set permalinks to "post-name"

  4. Save Changes

Screen shot illustrating steps outlined above

Gyromagnetic answered 26/12, 2018 at 9:0 Comment(3)
But see the comment by @Mohammad AlBanna https://mcmap.net/q/336842/-wordpress-jsonapi-wp-json-was-not-found-on-this-serverConfucius
Although it was already set, saving again fixed the issue for me.Eisenstark
Thank you! In contrast, I tried doing this and it didn't work, but then noticed that, whenever I clicked the link to edit pages, it took me to a URL which contained post=11. So, I tried setting the Permalink Structure to Plain, and that worked.Trauma
S
16

Sometimes the solution is crazy and easy! Go to the permalink settings by moving to Admin -> Settings -> Permalinks...then just hit Save Changes without doing anything else! This refreshes the memory of WordPress.

Why is that? For a situation I had before, I had changed the main website URL so I had to refresh the permalinks as well.

Subsequence answered 7/8, 2019 at 22:30 Comment(2)
I think this was just your situation, what is probably more important is what you had selected, perhaps "Post name"Fronton
@MaxCarroll this solution worked for me as well. I think it is more important to flush/reset the references. Clicking "Save Changes" affects database even if no visual changes are made.Confucius
P
9

I had this same issue and wanted to post my solution in case anyone else comes across this answer and the other answers don't solve the issue, as this happened with me.

In my case I didn't have a .htaccess file with Wordpress' default mod_rewrite rules:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

This solved the issue for me. Per the documentation:

WordPress uses this file to manipulate how Apache serves files from its root directory, and subdirectories thereof. Most notably, WP modifies this file to be able to handle pretty permalinks.

Pettway answered 16/10, 2019 at 1:41 Comment(2)
Perfect answer, but note that if this is the solution, you have a serious problem with your configuration. This can easily happen if you have migrated a WordPress installation to another place and forgot to do the stuff in one of the other answers: pressing "save changes" in settings->permalinks.Pachton
This worked for me as I was using %postname% permalink and was missing this file. I installed the site using Plesk.Dudleyduds
U
3

I was running WP on a local dev environment in a subdomain of localhost (eg mysite.localhost:8888)

The solution for me was to update the virtual host config in httpd-vhosts.conf to set directory options, similarly to Aurovrata's answer:

<VirtualHost *:8888>    
    ServerName mysite.localhost    
    DocumentRoot "/Users/myusername/mysite"    
    <Directory /Users/myusername/mysite>
        Options Indexes FollowSymLinks
        AllowOverride All        
    </Directory>
</VirtualHost>
Uropod answered 18/7, 2019 at 8:45 Comment(0)
A
1

Faced a similar issue, turns out that Apache's mod_rewrite module wasn't enabled. Worked fine after enabling it.

At answered 30/9, 2020 at 14:43 Comment(0)
S
1

For me, this issue was due to the WP site being developed at the root of a staging URL (ie example.com) but when put live it was installed in a sub-directory (ie example.org/wp)

Before I could make the suggestion from this comment work I had to chmod 664 .htaccess to make it writable by Wordpress. I then resaved the Permalinks as suggested and Wordpress updated the RewriteBase in .htaccess to /wp

Scyphus answered 8/11, 2021 at 13:3 Comment(0)
Y
0

If you have correctly installed the plugin, be sure to flush the rewrite rules.

This can be accomplished with the wp-cli: http://wp-cli.org/commands/rewrite/flush/

Yongyoni answered 29/12, 2015 at 22:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.