Make WordPress Core

#47217 closed defect (bug) (invalid)

Missing htaccess Activation Breaks Rest API

Reported by: prinzfranz Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.2
Component: REST API Keywords:
Focuses: Cc:


After Upgrading to 5.2 we suddenly had an issue with the Redirection-plugin. Checking Site Health Status turned up that the REST API was broken. Removing plugins did not solve the issue, so I installed a fresh WordPress demo and tried to reproduce the bug. I finally succeeded when setting the Permalinks-style to "Post name".
I tested the solution on the productive site and that solved my problem with the Rest Api. Of course I switched back to the original permalink style afterwards as I don't want to mess up SEO results.
As googling didn't yield anything pertaining to this problem as well as searching existing tickets I took the liberty of filing a bug report.

Attachments (2)

permalink-settings.png (98.0 KB) - added by prinzfranz 17 months ago.
site-health.png (74.4 KB) - added by prinzfranz 17 months ago.

Download all attachments as: .zip

Change History (9)

#1 @earnjam
18 months ago

  • Keywords reporter-feedback added

Welcome to WordPress Trac @prinzfranz!

This sounds like it may have been an issue with a plugin messing with the rewrite rules. I haven't been able to replicate this issue myself. I tried a fresh 5.2 install with permalinks style set to "Post name" and the REST API still worked for me.

Can you provide some step by step instructions as to how to reproduce the bug?

#2 @prinzfranz
17 months ago

  • Keywords reporter-feedback removed

Hi @earnjam,

thank you for your reply and sorry you can't reproduce the bug as non-reproducable bugs are bound to cause stomach-ache. What I just did to reproduce it is:

  • downloaded and installed a fresh instance of wordpress (https://wordpress.org/latest.zip, empty database, empty install directory)
  • after that, "Site Health Status" didn't show the warning concerning the REST API (just two warnings about unused plugins - Akismet and Hello Dolly - and unused themes)
  • then I set the URL structure in "Permalink Settings" to "Post name" and that's that, afterwards "Site Health Status" was/is showing the warning "The REST API encountered an unexpected result" (The requested URL /wp-json/wp/v2/types/post was not found on this server.)

The site is running on an Ubuntu 18.04.2 LTS server, Apache with PHP Version 7.3.5-1+ubuntu18.04.1+deb.sury.org+1. I'll try to attach images showing the Warning and Permalink-Settings. If there's any other information that could help I'll gladly provide it.

Many thanks and best regards!

#3 @prinzfranz
17 months ago

Hi @earnjam,

perhaps you could give me some guiding help where to find the code of the Site Health Status calls on the client as well as the receiving scripts on the server side? Then maybe I can sort out what's causing the trouble.

Thanks again and best regards!

#4 @earnjam
17 months ago

  • Keywords reporter-feedback added

Can you confirm permalinks are actually working when you change them? That is, can you view a page or a post on the front-end of the site at the pretty permalink URL? I'm wondering if your .htaccess file is not being updated properly to allow the rewrite rules to function properly.

#5 @prinzfranz
17 months ago

  • Keywords close added; reporter-feedback removed
  • Summary changed from Permalink Setting Post Name Breaks Rest API to MIssing htaccess Activation Breaks Rest API

Splendid! That solved it. Permalinks did work in fact, but rather accidentally thanks to our standard rewrite rules in the vhost file. Removing them and enabling .htaccess resolved the issue.

Thanks a thousand times for pointing me the right way, I was on a totally wrong track!

Best regards!

#6 @prinzfranz
17 months ago

  • Summary changed from MIssing htaccess Activation Breaks Rest API to Missing htaccess Activation Breaks Rest API

#7 @earnjam
17 months ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.