0

I been having some very frustrating issues with getting .htaccess to work on my new server. I'm not very experienced in managing a server, but I've spent the last three days pouring over documentation and every resource I can get my hands on.

I've attempted to try a very basic application of .htaccess, and yet it fails to give the expected results. I've setup a test directory. Immediately within this directory is an .htaccess file with the following command:

deny from all

If I'm not mistaken, this should deny access to /test, but it doesn't. It just sits there allowing anybody to view the contents. I've made a readable copy of the .htaccess available in the same directory for anybody wanting to see exactly what is going on in my .htaccess.

What could be wrong with my server/configuration? The server is running CentOS.

Response to Dom

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride None

As suggested, I changed this to AllowOverride All, and then restarted my server:

service httpd restart

But received the following message:

Syntax error on line 347 of /etc/httpd/conf/httpd.conf:
AllowOverride not allowed here [FAILED]

Line 347 is the last line below:

# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# The path to the end user account 'public_html' directory must be
# accessible to the webserver userid.  This usually means that 
# ~useridllowOverride controls what directives may be placed in 
# .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride None

1 Answer 1

2

Do you have AllowOverride All in your Virtualhost configuration ? if you have a AllowOverride None, the .htaccess file is not read, so it will not be used. And right,

deny from all

alone forbidden the connection to the folder. And don't forget to reload apache

18
  • Would the AllowOverride All be in my httpd.conf file?
    – Aristotle
    May 27, 2010 at 19:54
  • It depends of your platform. On my Debian/Ubuntu it is in /etc/apache2/sites-available/default, but you can configure all your apache in httpd.conf. Look for the "VirtualHost" parameter
    – Dom
    May 27, 2010 at 19:56
  • @Dom I found a reference to AllowOverride None in my httpd.conf file. Is this what you were referring to?
    – Aristotle
    May 27, 2010 at 19:59
  • Maybe if it is in the VirtualHost section. Could you put a copy of your httpd.conf in your server ?
    – Dom
    May 27, 2010 at 20:00
  • Sorry, I don't see your edit. No it is not the right : this is for the root directory, not your virtualHost
    – Dom
    May 27, 2010 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.