Hi! I gave some .txt files, which are being written form other php files. I want to protect them from being written only by me and bu no other IP address. The problem is that I am using 2 servers with 2 different IPs so I can not just choose "chmod 775" to be able only the owner to write to them, because, the other server is not owner of the files also. I think there must be some way to do that with .htaccess. Ideas?
One way would be to allow access if the remote address matches a predefined one.
if($_SERVER['REMOTE_ADDR'] == '192.168.10.1') // do stuff
I know that line of code since I am programming. I think you have not understand my question properly. Imagine the script is on location http://myweb.com/txtwriter/script.php and the .txt fil is in location: http://myweb.com/txtwriter/txtTOwriteIN.txt So, if I put this line in the script and you, after found a way to know the location of the .txt FILE create a script to write in it from your server, how could that line in my script stop you if the .txt file is 777 chmoded. 😉 I need a solution which to protect my file from being written only by selected IPs. Thx in advance
<Files "txtTOwriteIN.txt"> Order Deny, Allow Deny from All Allow from 192.168.10.1 </Files>
Alternatively, you could add an Apache handler to have TXT files parsed by PHP, which would allow for the last bit of code to work.
And I write this code in a .htaccess don't I?
Yes
Thanks