Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 470 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wordpress REST API (wp-api) 404 Error: Cannot access the WordPress REST API

#1
I have been using the Wordpress REST plugin WP-API for months now while developing locally with XAMPP. I recently migrated my site to an EC2 instance and everything is working fine **except** I now get a 404 with the following message whenever I try to access any endpoint on the API:

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

**Pretty permalinks are enabled** with the following structure `http://.../wordpress/sample-post/` which works fine when navigating to a specific post in the browser.

Here are some details about my setup:

- Wordpress 4.4.1
- **Not a Multisite**
- WP REST API plugin 2.0-beta9
- Apache 2.2.22
- Ubuntu 12.04.5

Any help would be greatly appreciated as I have gone through SO and the WP Support forums for several hours and am out of ideas. Thank you!
Reply

#2
It turned out to be a problem with the Apache configuration.

First, I deleted the `.htaccess` file in the root wordpress directory.

Next, I navigated to `/etc/apache2/sites-enabled` and opened `000-default`

All of the `AllowOverride` variables were set to None, which I replaced with `All`.

That did the trick!
Reply

#3
**UPDATED NEW WAY**

I also faced similar problem in a local project. **I used `index.php` after my project url** and it worked.

[To see links please register here]


**If it displays a 404 error then [update permalinks first](

[To see links please register here]

)** (see "Paged Navigation Doesn't Work" section

If it works, maybe you need to enable `mod_rewrite`, on ubuntu:

a2enmod rewrite
sudo service apache2 restart


## Installation

> The REST API is included in WordPress 4.7! Plugins are no longer required, just install the latest version of WordPress and you're ready to go.

If you're before 4.7:

1. Download plugin from here:

[To see links please register here]


2. install and activate it.

## Usage

To get all posts:

[To see links please register here]


For the search functionality, searching for test post looks like this:

/wp-json/wp/v2/posts?filter[s]=test
Reply

#4
I had this problem with the latest WordPress 4.7+. In my case the REST API only worked after I changed the permalinks setting to something other than "Plain", which was the default setting for my installation.
Reply

#5
On WPEngine and WP 4.9.2 I only had to update permalinks to get fresh, newly installed site to return v2 API calls. What I did:

1. Create site
2. Browse to

[To see links please register here]

- get 404
3. Go to admin, settings, permalinks, choose "Post Name"
4. Click "Save Changes"
5. Browse to

[To see links please register here]

- success. page displays JSON response
Reply

#6
**I had to manually make a `.htaccess`, set it to `chmod 664`, and copy the permalink rules into it.**

*I also played around with*

- Settings > Permalinks
- Manually updating .htaccess via the code at the bottom of the permalinks page after clicked "Save"
- Adding "index.php" as one of the other answers suggests
- Making sure `mod rewrite` was enabled via `a2enmod`
Reply

#7
I had moved the WordPress install from a subdirectory to another, so in my case the problem was due to the WordPress config in the `.htaccess` files. It was trying to redirect every page but the homepage to the old directory. It was just a matter of updating `olddir` to `newdir`...
This tripped me up more than once so I thought I'd put it here...

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

# END WordPress
Reply

#8
I solved this issue through following steps:

1. Navigate to ..\Apache24\conf\httpd.conf and search for `LoadModule rewrite_module modules/mod_rewrite.so`.

2. Enable rewrite module by removing the `#` mark.

3. Replace all the cases of `AllowOverride None` to `AllowOverride All`.

4. Don't forget to restart apache server. :)
Reply

#9
I found that `mysite/wp-json/` was not working, but `mysite/?rest_route=/` was normal. This was breaking some, but not all, the REST API features used on my site.

The answer to this turned out to be a recent change to how I was running my server. This had broken REST API but this was not apparent until later.

I had changed this domain from using Apache to using nginx, and I had not correctly transferred the `.htaccess` customisations. The quick solution to this problem was therefore to change back to using Apache. This restored the site to working order immediately.

I will be changing this domain back to nginx in the future but when I do, I will test it and be careful not to affect the REST API.
Reply

#10
It is the file permission **error**, apply the following **solution**:

Edit this file `/etc/apache2/apache2.conf`
Change `/var/www/` Permissions from "None" to "All"
Restart the `apache2` server.

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through