I want to hide a specific content of a text file. Let's say we have a file named (test.txt) and the content of the file is :
data1
data2
data3
the (test.txt) file can be accessible by visiting http://example.com/test.txt. What i want to do is to hide the LINE:3. so when the file is requested it will show only:
data1
data2
what i normally do under apache server is I create a (.htaccess) file and put this following content inside it :
Options -Indexes +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-r
RewriteRule ^(.?)ads\.(.?) somehiddenfolder/hide.php [NC,L]
and i create a hide.php file somewhere inside the server with the following code :
<?php
echo file_get_contents("../../test.txt")."\n";if(!strpos(strtolower($_SERVER['HTTP_USER_AGENT']),"my-user-agent")){die();}?>
data3
now what will happen is (data3) will only be printed if the user agent is corresponding to the hide.php
MyQuestion:
Is there a workaround under NGINX server ? because .htaccess doesn't work !
Any help will be appreciated. Thanks.