File security options

Status
Not open for further replies.

muggy8x1

New Member
Messages
4
Reaction score
0
Points
1
Hi I have a collection of files in a folder that I have. I would like to ask that if at all possible disallow anyone from viewing (but still allows execution) of the HTML files within the folder but leaves all other files perfectly accessible and readable. Thanks
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
Hello muggy8x1,

I believe this is possible with .htaccess. You could create a .htaccess file in the folder you want to hide, and insert the htaccess cocde inside it. Though I'm not an expert with .htaccess, I think the following should work:

Code:
deny from all

I could be wrong though, as I'm not very experienced with .htaccess.

Thank you,
 

muggy8x1

New Member
Messages
4
Reaction score
0
Points
1
I've tried doing this but for some reason the server would not recognize my .htaccess file :(
 

usama_rasab27

Member
Messages
208
Reaction score
15
Points
18
Hi muggy8x1, when you go to your file manager in cpanel, make sure you click 'Show hidden files' and then go the folder that you want and check if your .htaccess file is there, if not try to make it again. And I added something to what Dead-i told you to put in your .htaccess. Instead of hiding it from everyone including yourself, use this.

Code:
order deny,allow
deny from all
allow from 123.123.123.123

Replace the 123.123.123.123 with your ip address.

You can get your ip by making a file on filemanager named ip.php, then paste the following code:

PHP:
<?php

$ip = getenv(REMOTE_ADDR);

echo "Your IP Address is ".$ip;


?>

Then, go to ip.php on your domain on a browser. Then, copy and paste the ip address that you get into your .htaccess file.

Thank You
 
Last edited:

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
You can also use something like http://www.whatismyip.com to get your IP address.

The problem is your IP address is likely to change every once in a while. If you notice that you can't see the HTML files with a 403 forbidden error, then edit the .htaccess file and put in your new IP address.

You may want to consider using the "Password Protect Directory" tool in CPanel instead; this will ask for a password instead of requiring IP address information.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
1. What do you mean "still allows execution" of HTML files?
2. Does the folder contain both kinds of files, accessable and inaccessable?
3. Why not just set the permissions to 0222 ?
 
Status
Not open for further replies.
Top