locate .htaccess file

Hi,

I am noob on linux so sorry if this question sounds stupid.

I have installed apache2 on centos 5 using this tutorial (http://library.linode.com/lamp-guides/centos-5/).

I want to remove directory listing feature. that is, when someone, types http://mysite.com/abc/

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

Hi there

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!! :)

Hi,

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 :)

Hi mikeindia

I'm glad that helped!! :D

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.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct