mr_bob Posted July 23, 2021 Share Posted July 23, 2021 Hi all, Following advice of one member here I managed to write following rules. It's needed to block direct access, but allow files to be read by html code like this: RewriteEngine On RewriteCond %{HTTP_REFERER} !^(www\.)?domain\.com [NC] RewriteCond %{HTTP_REFERER} !^(www\.)?domain\.com.*$ [NC] RewriteRule \.(gif|jpg|mp3|ogg|)$ - [F] It's needed for www.domain.com and https://domain.com. Problem is that page.html doesn't display images and mp3 files after that. [L] at the end allows them display but direct access too. What could be wrong here? Quote Link to comment Share on other sites More sharing options...
requinix Posted July 23, 2021 Share Posted July 23, 2021 If you view a page at https://www.domain.com/page.html and it tries to show an image from https://www.domain.com/image/img.jpeg, what do you think the referrer string will be? Also, you cannot rely on the referrer string even being present. You should only block access if there is one. Quote Link to comment Share on other sites More sharing options...
mr_bob Posted July 23, 2021 Author Share Posted July 23, 2021 Just now, requinix said: If you view a page at https://www.domain.com/page.html and it tries to show an image from https://www.domain.com/image/img.jpeg, what do you think the referrer string will be? Also, you cannot rely on the referrer string even being present. You should only block access if there is one. I guess we're missing jpeg here which should be added to the list. Maybe I should declare /image/ directory? Regular expressions are hammering me. Quote Link to comment Share on other sites More sharing options...
requinix Posted July 23, 2021 Share Posted July 23, 2021 I think you missed the question. The referrer will be an absolute URL... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.