htaccess – Only expose routes with prefix /wp-json on WordPress using Apache
I want to only expose routes with the /wp-json prefix so that I can use headless WordPress without exposing the rest of my WordPress site to the internet.
I’m running this on Apache, but haven’t yet figured out the proper syntax for .htaccess.
So far I have tried:
<Directory /> AllowOverride None </Directory> <Directory /wp-json*> AllowOverride All </Directory> <Directory /wp-json*/*> AllowOverride None </Directory>
<Directory "/wp-json/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from all </Directory>
My .htaccess is located inside of the
public_html root directory. I’m not sure if I’ve got the .htaccess in the wrong directory or, if the syntax I’m using just isn’t working. Any tips?