0

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]
saurabhlahoti
  • 466
  • 8
  • 21
  • It is not possible. The JS file must be accessible from direct URL if you want to embed it in page. – ghost Oct 20 '14 at 06:16
  • Then how can i protect the content of my JS file and at the same time use it from my page ? suggest me some technique – saurabhlahoti Oct 20 '14 at 06:21
  • maybe check if `$_SERVER['SCRIPT_FILENAME'] === __FILE__` in the js file (create a php file and have a header as text/javascript) but that might cause some problems – Class Oct 20 '14 at 06:22
  • I don't think there is any good way to completely protect your scripts. You can make them harder to read by obfuscating them or using javascript minifiers / packers. – ghost Oct 20 '14 at 06:25
  • i heard about one method. Can you please suggest me the way to do it. Method is blocking every other IP than mine from accessing a certain file type on server. How to do this? – saurabhlahoti Oct 20 '14 at 06:38
  • `order deny,allow deny from all allow from [ip]` and this is for htaccess [Htaccess: Deny all, allow only one ip](http://stackoverflow.com/a/4400412/1700963) – Class Oct 20 '14 at 07:08

0 Answers0