Hi sammyr , thanks for sharing the .htaccess
file! That's it! I wish I had asked this earlier.
In your htaccess
you have the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
</IfModule>
This code redirects all request which don't end with a /
. For example, site.com/some-title
redirects to site.com/some-title/
. These redirects are also happening for the WordPress REST API, which should never happen as these request should have kept intact. Buttonizer and many other plugins are using this WordPress API and don't expect the request to be redirected.
Can you replace the code above to:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteCond %{REQUEST_URI} !^/(wp-json)
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
</IfModule>
As you see I've added RewriteCond %{REQUEST_URI} !^/(wp-json)
to the code, this means that the redirect of site.com/some-title
still works, but the WordPress REST API, site.com/wp-json
is not affected.
I am wondering, why do you have this code in the .htaccess
in the first place, is it because of the https
redirect? WordPress should automatically redirect posts and pages to their correct URL if they are misspelled or are missing the slash as far as I know.
Let me know if this was the solution! 🙂