First you need to enable the apache rewrite module with the following command:
sudo a2enmod rewrite
then we must edit the configuration file of our virtual host
sudo nano /etc/apache2/sites-available/your_config.conf
and add in the following directive
<Directory /var/www/your_root_directory>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
note: change your directory path
now our file should look like this
<VirtualHost *:80>
<Directory /var/www/your_root_directory>
. . .
</Directory>
ServerName midomain.com
. . .
</VirtualHost>
Now Restart the service of apache
sudo service apache2 restart
create a .htacces file in your root directory of your web site
sudo nano /var/www/your_root_directory/.htaccess
and finally add into .htaccess
RewriteEngine on
RewriteRule ^wp-json/wp/v2/posts$ ?rest_route=/wp/v2/posts [NC]
http://localhost/wp-json/? What version of wordpress? Using plugin or built in version ofwp-json? Sure not much detail provided here