Title: REST API URL path processing bug?
Last modified: February 4, 2017

---

# REST API URL path processing bug?

 *  [chishomi](https://wordpress.org/support/users/chishomi/)
 * (@chishomi)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/rest-api-url-path-processing-bug/)
 * In brief, the problem appears to be that my site’s “home” URL path is “wp”, which
   just happens to be a prefix of the REST API’s path prefix “wp-json”, so it’s 
   stripping the prefix off and trying to match the rewrite rule patterns against“-
   json”. That breaks it.
 * So here’s more detailed information:
 * I’ve been tinkering with WordPress locally via Wampserver (3.0.6). I have added
   an alias to the embedded apache config, in the virtual host:
 *  Alias “/wp” “c:\path\to\wordpress”
 * So to access wordpress, I go to
 *  [http://localhost/wp](http://localhost/wp)
 * That’s also the site’s “home” URL (i.e. the actual “home” option setting in the
   wp_options db table). And it has worked fine, up until I started experimenting
   with the REST APIs.
 * I am accessing the REST API following a clue in the comments regarding a “path
   info request”, for example:
 *  [http://localhost/wp/index.php/wp-json/wp/v2/posts](http://localhost/wp/index.php/wp-json/wp/v2/posts)
 * When I do this, relevant PHP global values are:
 *  _SERVER[‘PATH_INFO’]: /wp-json/wp/v2/posts
    _SERVER[‘REQUEST_URI’]: /wp/index.
   php/wp-json/wp/v2/posts
 * The problem is in the post-processing of the path info, in [WP::parse_request()](https://core.trac.wordpress.org/browser/tags/4.7.2/src/wp-includes/class-wp.php#L196).
   It’s stripping off the home path from the beginning of the path info value, which
   results in “-json/wp/v2/posts”. That means the rewrite rules aren’t matching 
   as they should. If I comment out line 196, then it works. Also, it seems like
   if I hadn’t coincidentally created my apache alias with letters which formed 
   a prefix of “wp-json”, this wouldn’t have happened (though I haven’t tested this;
   I’m not sure I can change the alias without also needing to hack WordPress settings
   like the “home” setting). So it seems like a subtle coincidence which may have
   revealed a bug.
 * Is this a bug? If the path info comes after “index.php” in the URL, and the home
   path comes before, why would the home path ever occur in the path info? Why would
   it need to be stripped?
 * My background: I’ve been a dev for many years, but this software stack is new
   to me. So it is possible I’ve messed something up too 🙂
    -  This topic was modified 9 years, 4 months ago by [chishomi](https://wordpress.org/support/users/chishomi/).
      Reason: Add some background info about me

The topic ‘REST API URL path processing bug?’ is closed to new replies.

## Tags

 * [rest](https://wordpress.org/support/topic-tag/rest/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [chishomi](https://wordpress.org/support/users/chishomi/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/rest-api-url-path-processing-bug/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
