Rewrite /?rest_route=/ link to /wp-json/ without changing default permalink structure in apache

How to rewrite url of wordpress rest api from http://example.com/?rest_route=/wp/v2/ to http://example.com/wp-json/wp/v2/ without changing (default) permalink structure? Need this for apache (htaccess).

In nginx it would be like this:

location ~ ^/wp-json/ {
rewrite ^/wp-json/(.*?)$ /?rest_route=/$1 last;
}

1 Answer
1

Solved by this lines:


RewriteEngine On
RewriteBase /
RewriteRule ^wp-json/(.*) /?rest_route=/$1 [L]

Leave a Comment