htaccess – Only expose routes with prefix /wp-json on WordPress using Apache

Question

Pretty straightforward:

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>

and

<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?

0
Brad 2 weeks 2021-07-14T23:49:50-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse