0

Is it possible to restrict access to a public URL to a single IP? For example, let's say I had this url:

www.mydomain.com/file.txt

I would like to parse this TXT file by another server and block everyone else from attempting to access it. Is this possible?

Andrew
  • 2,691
  • 6
  • 31
  • 47

2 Answers2

2

Something like this should work (obviously change the IP to the address or block you wish to allow):

<Location /file.txt>
Order deny,allow
Deny from all
Allow from 123.123.123.123
</Location>
John Conde
  • 217,595
  • 99
  • 455
  • 496
  • Great - thank you! How secure is it? Is there a way for hackers to get around this? – Andrew Jun 16 '13 at 14:38
  • Only if your server or the computer at that IP address is compromised. But at that point you have much larger problems. :) – John Conde Jun 16 '13 at 14:39
1

use htaccess

<Files "file.txt">
    Order deny, allow
    Deny from all
    Allow from 127.0.0.1
    Allow from .mydomain.com
</Files>
amigura
  • 541
  • 3
  • 6
  • Thanks @ amigura. I gave you a +1 but I'll give @John Conde accepted answer cause he was first ;) – Andrew Jun 16 '13 at 14:39