2

My clean install of Wordpress is responding with a 404 at /wp-json.

The URL I'm using is temporary in the format http://111.222.333.444/~account/

I can access the blog at http://111.222.333.444/~account and wp-admin at 111.222.333.444/~account/wp-admin. I can't access wp-json at 111.222.333.444/~account/wp-json/

I've tried both Wordpress 4.7.5 and 4.7.4. I've installed through Installatron (4.7.5 and 4.7.4) and Softalicious (4.7.5 only) and neither work.

My host uses a LiteSpeed server. There are no .htaccess files in obvious directories. I am using the same host for another Wordpress instance (also 4.7.5) and its /wp-json/ works fine.

On one install attempt, /wp-json/ responded with the blog home page rather than a 404.

I have tried inserting index.php in the URL (i.e. 111.222.333.444/~account/index.php/wp-json

... and I've run out of ideas. Any help, please?

Andrew Mackie
  • 344
  • 3
  • 13
  • what is your permalink setting? I assume you're not set your website's permalink yet.. For sites without “pretty permalinks” enabled, /wp-json/ isn’t automatically handled by WordPress. This means that normal/default WordPress permalinks will be used instead. http://v2.wp-api.org/guide/discovery/ – rheeantz May 23 '17 at 11:57
  • Thanks Ryan - that solved it. If you make it an answer I'll upvote it. But please permit me a short rant about Wordpress: Why are 'ugly' links the default? If they want the REST API to be on by the default, why make it *dependent* on having pretty links? If it really needs to be this way, why isn't it much more obvious in the documentation rather than buried in the 'discovery' section (everything else seems to say 'just go to /wp-json/'? Feeling better now - thanks again. – Andrew Mackie May 23 '17 at 22:33

1 Answers1

0

Write it as answer based on my knowledge about wordpress.

By default all of urls on a wordpress website are looked "ugly". For example :

a single post will looks like = website.com/wp/?p=1

a page will looks like =website.com/wp/?page_id=2

and a category will looks like website.com/wp/?cat=1

and for wordpres rest api will be website.com/?rest_route=/ or website.com/?rest_route=/wp/v2/

After a wordpress website set permalinks except plain permalink wordpress will give add rewrite rule for wp rest api url into website.com/wp-json/ or website.com/wp-json//wp/v2/ , but for rest api you still can access it with default plain url website.com/?rest_route=/.

I hope this litle explanation can give you information you need about wp rest api.

rheeantz
  • 960
  • 8
  • 12