locate .htaccess file
I am noob on linux so sorry if this question sounds stupid.
I have installed apache2 on centos 5 using this tutorial (
I want to remove directory listing feature. that is, when someone, types
He should not see files in that folder.
For that, there is a way to do in .htaccess,
Options -Indexes
I did grep -i AllowOverride httpd.conf and i got
AllowOverride None
# AllowOverride controls what directives may be placed in .htaccess files.
AllowOverride None
# AllowOverride FileInfo AuthConfig Limit
# for additional configuration directives. See also the AllowOverride
AllowOverride None
AllowOverride None
AllowOverride None
So, my question is
1) where do i find .htaccess file? (All, php and .html files are in var/www/html )
2) AllowOverride is None, so will my .htaccess file work?
Thanks
4 Replies
You won't find the .htaccess file. You will need to create it in the directory that you do not want to have a directory listing.
I presume the directory is: /var/www/html/abc/
The .htaccess file is a normal text file and needs to contain only this information:
Options -Indexes
You could run these commands to get everything up and running…
touch /var/www/html/abc/.htaccess
echo "Options -Indexes" >> /var/www/html/abc/.htaccess
You will probably need to change the AllowOverride option in your httpd.conf file from AllowOverride None to AllowOverride All.
Save the httpd.conf file and restart the Apache service.
Try that and let us know if it helps!! :)
i created .htaccess in abc/
and changed
# AllowOverride controls what directives may be placed in .htaccess files.
AllowOverride None
to
# AllowOverride controls what directives may be placed in .htaccess files.
AllowOverride All
in httpd.conf file.
then restarted Apache (or did /etc/init.d/httpd reload)
and worked like a charm.
Thanks czotos
I'm glad that helped!!
The instructions for doing this on Debian-based systems (e.g. Debian/Ubuntu) are the same, but it's worth noting that instead of editing httpd.conf
to allow .htaccess
overrides, you should edit /etc/apache2/apache2.conf
.