Custom url WordPress REST API
-
I’m building an app which uses data from a WordPress backend. Most of the data is cached in JSON files on the server, but the app allows comments to be placed, so the API has to be called from within the app. I’m worried that when WordPress decides to change the URL from /wp-json/wp/v2/ to /wp-json/wp/v3/ I have to update the apps that use the URL. That is why I was hoping to rewrite this URL to something more generic like /api/.
Is this possible? My first attempt failed and simply shows the index.php from the theme directory:
RewriteRule ^api/(.*)$ /wp-json/wp/v2/$1 [NC,L]
- The topic ‘Custom url WordPress REST API’ is closed to new replies.