Title: custom url
Last modified: April 21, 2017

---

# custom url

 *  [vespino](https://wordpress.org/support/users/vespino/)
 * (@vespino)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/custom-url-21/)
 * 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]

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [mksamadnet](https://wordpress.org/support/users/mksamadnet/)
 * (@mksamadnet)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/custom-url-21/#post-9131487)
 * Hello [@vespino](https://wordpress.org/support/users/vespino/),
 * Just add the following filter to your functions page to change the API base. 
   The below will change the REST api route from example.com/wp-json/wp/v2/ to example.
   com/api/wp/v2/.
 * I don’t think changing the namespace is good idea!!.
 * add_filter( ‘rest_url_prefix’, ‘my_theme_api_slug’);
    function my_theme_api_slug(
   $slug ) { return ‘api’;
 * }
 *  Thread Starter [vespino](https://wordpress.org/support/users/vespino/)
 * (@vespino)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/custom-url-21/#post-9131658)
 * That is something I already found but does not quite solve the issue, does it?
   If the guys at WordPress decide to change /v2 to /v3 I still have the same problem.
 *  [mksamadnet](https://wordpress.org/support/users/mksamadnet/)
 * (@mksamadnet)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/custom-url-21/#post-9131859)
 * There is something called register_rest_route to create custom API routes. I 
   don’t have much idea about.
 * Does this logic work for you
 * Inside app – > fetch the value of comment API dynamically
 * For example read a text file over url which has the comment API URL mentioned.
   Even if the comment url changes in the future, you can simply change the URL 
   in the text file the same will be reflected in the app coding?
 * Does it work for you?
 *  Thread Starter [vespino](https://wordpress.org/support/users/vespino/)
 * (@vespino)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/custom-url-21/#post-9132482)
 * That would work, but only as a final resort since I believe this creates unnecessary
   traffic to the server and certain values must be set on the server.
 *  [mksamadnet](https://wordpress.org/support/users/mksamadnet/)
 * (@mksamadnet)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/custom-url-21/#post-9139079)
 * I’m not an expert developer. But, my logic says that there should be a file which
   will check by the app every time and should work based on the data on the file.
 * For example: The remote file should have a variable named Force_update: this 
   value either be yes or no. If in case you find any major bug in your previous
   app release, you can just refer it as yes and can force the users to update the
   app.
 * I’m not sure whether any other option available inside android development toolkit
   to deal with such issues!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘custom url’ is closed to new replies.

 * ![](https://ps.w.org/rest-api/assets/icon-256x256.png?rev=1346297)
 * [WordPress REST API (Version 2)](https://wordpress.org/plugins/rest-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/rest-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/rest-api/)
 * [Active Topics](https://wordpress.org/support/plugin/rest-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/rest-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/rest-api/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [mksamadnet](https://wordpress.org/support/users/mksamadnet/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/custom-url-21/#post-9139079)
 * Status: not resolved