newbie in php language here and was woundering if there is a way to prevent access to a vital folder of my website from all except a certain php page . and if there is a way to do so can i just access the folders content via directory path/to/secret/folder or i have to request the data in some other way from the page (that i want to be only way to access said folder)
any detailed information about the website would be the folder i like to lock is inside htdocs (public folder) the content inside the folder i want locked is images
any help would be welcome
I created a folder test on my beta.adisp007.ml subdomain.
After that, I created 4 files inside it: .htaccess, index.php, page.php, & allow.php.
I configured that .htaccess file so people only can access allow.php file on that folder.
If someone access except allow.php file, they will be redirected to forbidden page. http://beta.adisp007.ml/test/allow.php (you can access this page) http://beta.adisp007.ml/test/page.php (you can’t access this page & the rest inside that folder)
Its .htaccess code is same:
Deny From All
Allow From All
Only changed processing.php to allow.php accord to my files structure.
alright man i think i should be more clear in my question sorry for that
i have a folder which contains 4 subfolders each containing images
i want access to this folder its subfolders and files(images) denied to all except coming from a file.php so .htaccess goes inside main restriced folder .
and the .htaccess >>>path to >>> file.php would be “…/inc/file.php”
if this would be possible i wont have to use script and have to use less hits per user
So,you mean you want to forbid access to the images, but still want to view them on file.php file (for example by using <img> html tag)?
No code can do it. You can choose one choice, man.
Once you forbid access to public,then public can’t access it.
Even if you can allow file.php to access the images, but in the end you or some people that access file.php are public. The images won’t be generated.
But you can make certain people to access them, for example your IP or/and your hosting IP (file.php).
so your hosting ip(file.php) if this is possible this would do it , wouldnt it ?
the filephp would be public but the images priavte and visitors request filephp which requests images , would that be possible
thanks again for the replay.
With my little knowledge i think this prevents access from certain files except requested by the given ip.
If this is the case iam afraid it will not do because in the end diffrent people will request thier images from diffrent ips and should get them (the purpose of the site)
What i specificaly want is for the folder or files inside that folder which will be jpg, jpeg or both to be inaccessable throu out typing thier mysite/path/file.jpg
But also user can only access them when requested by file.php .
Sorry if my explaining is not all that good