I have a folder full of folders with json files. I want to restrict AJAX requests to these files to certain domains.
I made an htaccess file to restrict this but it isn't work. My htaccess is as follows:
Require host thedomain.com
Require host thehurts.com
Require all granted
What you need is to limit it from the source.
You should be able to set environment variables for referring domains and then include that in the rule. Then you can do by IP address to limit it coming from the server or your IP address also.
SetEnvIf Referer "example\.com" localreferer SetEnvIf Referer "example2\.com" localreferer2 <FilesMatch "\.json$"> Require env localreferer Require env localreferer2 Require ip x.x.x.x #your ip address Require ip 127.0.0.1 #localhost Requite ip x.x.x.x #replace with your local server IP. </FilesMatch>
See if that helps.