WordPress.org

Ready to get started?Download WordPress

Forums

JSON REST API (WP API)
[resolved] URL rewrite from /wp-json.php to /api (4 posts)

  1. markzero
    Member
    Posted 5 months ago #

    Is it possible to do rewriting from site.com/wp-json.php/ to site.com/api/?

    I'm using nginx and have such rewrite rule:
    rewrite ^/api/(.*) /wp-json.php/$1 break;

    But it doesn't work, but other rewrites do work using identical logic.
    Any help?

    https://wordpress.org/plugins/json-rest-api/

  2. B
    Member
    Posted 5 months ago #

    Try no slash after wp-json.php.

    rewrite ^/api/(.*) /wp-json.php$1 break;

  3. Ryan McCue
    Member
    Plugin Author

    Posted 4 months ago #

    At the moment, you have to edit the main file yourself. I've filed an issue for this. Thanks!

  4. nicshel2
    Member
    Posted 2 months ago #

    Hi Ryan,

    I'm trying to do the same myself.

    When you said edit the main file, which file /files do you mean ?

    I've tried updating :
    add_rewrite_rule( '^wp-json/?$','index.php?json_route=/','top' );
    add_rewrite_rule( '^wp-json(.*)?','index.php?json_route=$matches[1]','top' );

    But it didn't work, it still expects wp-json.

    Thanks,

    Lisa

Reply

You must log in to post.

About this Plugin

About this Topic