Reputation: 303
I am trying to redirect users without a cookie "wordpress_logged_in" from the "wp-json/" to the base url of the website. Unfortunately when I go to the url "wp-json" nothing changes and the JSON shows as normal. When I test the script to a directory that exist on the server (folder called "test") the script works fine.
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,QSA]
RewriteCond %{HTTP_COOKIE} !.*wordpress_logged_in.*$ [NC]
RewriteCond %{REQUEST_URI} ^.*wp-json/wp/v2/(users|comments|posts|pages|media|types|statuses|taxonomies|categories|tags|settings) [NC]
RewriteRule . http://%{HTTP_HOST}%1/wp-login.php?redirect_to=%{REQUEST_URI} [L,QSA]
Incognito mode, clearing cookies/history/cache, different browsers, different web servers, I've tried creating the wp-json folder but that breaks the API
Any ideas would be much appreciated!
Upvotes: 5
Views: 979
Reputation: 303
I figured out the "wordpress_logged_in" was changing due to a plugin that was installed. I think that solves the misery.
Upvotes: 2