• Hi all.

    Since December (I suspect since the most recent WordPress update), our blog appears to generate a vast amount of broken links (about 80 right now) as indicated by external services such as Linktiger.

    I don’t understand where those broken links come from. They are urls that never existed, as far as I know, and that should not exist. What they have in common is that they include /blog/wp-json/ – in some cases /blog/wp-json/jetpack/

    Does anyone know where these things come from and what I can do to get rid of them?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Those are REST API endpoints. They are listed in meta tags in the head section. Unless you’ve disabled REST, they are not broken links, but they return JSON data, not a typical web page. They may appear broken to something superficial like Linktiger. If it knew how to read JSON, the links should work just fine.

    Thread Starter hkhall

    (@hkhall)

    Hi bcworkz.

    That sounds reassuring, but I’m afraid I have to ask questions as I don’t fully understand. What are REST API endpoints? What are JSON data and why do they need to be returned, and to whom? If Linktiger (for example) does not know how to read JSON, what does? If I click on those links, I get various no-access pages (401 usually). What is the purpose of these pages, do I need them and if not, how can I get rid of them?

    HH

    Moderator bcworkz

    (@bcworkz)

    I’m not sure why REST URLs return 401. That is not normal, and would explain why Linktiger said they were “broken”. 401-unauthorized is hardly the same as 404-not found (broken) though. REST endpoints are URLs one can use to get particular information from your site using the REST API. JSON is the data exchange standard. It’s like XML, but different. It’s essentially a JavaScript data array.

    All sorts of apps, particularly mobile, use REST and understand JSON data. It sounds like something may have disabled REST already, hence the 401s. We’d think removing REST links would be part of disabling REST, but it’s not as simple as it sounds to do this. Do you have a security plugin? That may be the cause of the 401s. As more people only interface with the Internet with mobile devices, REST is becoming more of a method to get data from websites. I would advise not disabling REST as you could be locking out legitimate mobile users accessing your site through a mobile app.

    If you still want to remove the links, you should first determine which plugin is causing the 401 response. If you deactivate all of your plugins, the main REST link should return a bunch of JSON data with 200 status. example.com/wp-json/

    Reactivate each plugin until the 401 starts again. That last plugin is what is “disabling” REST. There are a few plugins that disable REST, see if any of them remove links, They may conflict with the 401 plugin, so leave that deactivated when you are evaluating other plugins.

    If you can’t find a plugin to remove links, you can attempt to remove them through custom code. The main link is added through a “wp_head” action hook. You can remove the hook after the system adds it. The callback rest_output_link_wp_head() was added with priority 10. How to remove the other links depend on how they got there. Themes and plugins add their own links to provide REST functionality for whatever they do. Each one adds their link differently. You can try searching through the global $wp_filter to identify added hooks. It’s far from predictable, which explains why plugins may not remove links.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Lots of broken links – JSON’ is closed to new replies.