austinh
austinh

Reputation: 1071

Protect folder on server only allow requests from allowed sites

Is there a way to not allow anyone to have access to the contents of a folder unless the were referred by a certain site? So if someone tried to load music.mp3 can I redirect them, but if example.com referred them allow them to see it. Would this be done through .htaccess?

Thanks!

Upvotes: 0

Views: 71

Answers (1)

exussum
exussum

Reputation: 18550

something like

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www\.example\.com [NC]
RewriteRule \.jpg - [F]

should work

if its not http://example.com then give 403 status code

Upvotes: 1

Related Questions