asmith Posted January 1, 2008 Share Posted January 1, 2008 i have a folder name "files" . i want to forbid the access to it ,i mean if someone type in the address bar : www.domain/part1/files/ it gave him error . as i read somewhere else on this forum , i made an .htaccess file , with no content but "Options -Indexes". i put that in files folder, but when i type the address, it still shows me the content of the folder, what thing i'm doing wrong ? Quote Link to comment https://forums.phpfreaks.com/topic/83974-htaccess/ Share on other sites More sharing options...
sKunKbad Posted January 1, 2008 Share Posted January 1, 2008 I think you would do something like this: <Location /yourFolderName/> deny from all </Location> Quote Link to comment https://forums.phpfreaks.com/topic/83974-htaccess/#findComment-427340 Share on other sites More sharing options...
asmith Posted January 1, 2008 Author Share Posted January 1, 2008 i don't get it , i should put it in the .htaccess ? is that in php.ini ?? Quote Link to comment https://forums.phpfreaks.com/topic/83974-htaccess/#findComment-427343 Share on other sites More sharing options...
sKunKbad Posted January 1, 2008 Share Posted January 1, 2008 I modified it, go up and see. No, it isn't the php.ini. You would create a file called .htaccess and upload it to your root directory (assuming Apache is running on your server). Quote Link to comment https://forums.phpfreaks.com/topic/83974-htaccess/#findComment-427347 Share on other sites More sharing options...
asmith Posted January 1, 2008 Author Share Posted January 1, 2008 am i being so stupid ? i can't get it to work , i made : .htaccess <Location /yourFolderName/> deny from all </Location> and put that in http://localhost/mysite/file/ but still shows the index of files!! (yes i'm using apache 2.2.6) Quote Link to comment https://forums.phpfreaks.com/topic/83974-htaccess/#findComment-427350 Share on other sites More sharing options...
sKunKbad Posted January 1, 2008 Share Posted January 1, 2008 if you want it to work on your localhost, then you will probably have to modify the httpd.conf file. Quote Link to comment https://forums.phpfreaks.com/topic/83974-htaccess/#findComment-427351 Share on other sites More sharing options...
asmith Posted January 1, 2008 Author Share Posted January 1, 2008 ah , that's not a thing tat would run o localhost ?? i thought there's no difference between a localhost and a real web host! Quote Link to comment https://forums.phpfreaks.com/topic/83974-htaccess/#findComment-427354 Share on other sites More sharing options...
sKunKbad Posted January 1, 2008 Share Posted January 1, 2008 well, I'm no Apache guru, but I think that the .htaccess files have to be "turned on" in the httpd.conf, so in that regard localhost may not be like your real web host. see http://httpd.apache.org/docs/1.3/mod/core.html#allowoverride Quote Link to comment https://forums.phpfreaks.com/topic/83974-htaccess/#findComment-427527 Share on other sites More sharing options...
we4freelance Posted January 2, 2008 Share Posted January 2, 2008 Hello Smith, According to me you just create 1 blank index.html and put it in your folder and no one can see its content. I think this will help. Quote Link to comment https://forums.phpfreaks.com/topic/83974-htaccess/#findComment-428342 Share on other sites More sharing options...
sKunKbad Posted January 3, 2008 Share Posted January 3, 2008 asmith, just go in to your httpd.conf file and in the two places you see: AllowOverride None change them to AllowOverride All and you are good to go. Quote Link to comment https://forums.phpfreaks.com/topic/83974-htaccess/#findComment-428851 Share on other sites More sharing options...
Daniel0 Posted January 4, 2008 Share Posted January 4, 2008 Options -Indexes will not show the file list if you access the folder. I.e. http://example.com/folder will give a 403 Forbidden error but files can still be access, i.e. http://example.com/folder/file.ext will show. Deny From All will give a 403 Forbidden error on both file listings and files. So, if you want to hide the file listing but allow users to access the files use the former, if you wish to deny ALL access to all files use the latter. In order to use the former in a .htaccess file placed in the folder you wish the settings to have effect on AllowOverride Options must be set. For the latter AllowOverride Limit must be set. You can also set AllowOverride All which will enable all directives in .htaccess files. You can also put it in your httpd.conf file, but in order for this to work only on the folder you wish you use enclose it with <Location /path/to/folder> (path is relative to document root) and </Location>. Quote Link to comment https://forums.phpfreaks.com/topic/83974-htaccess/#findComment-430352 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.