i used this to block access from URL but it also blocked its access from my php page.
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain\.ltd [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain\.ltd.*$ [NC]
RewriteRule \.(gif|jpg|js|txt)$ /messageforcurious [L]