Wednesday, August 26, 2009

Apache Web Server .htaccess File , AllowOverride All, Order deny allow

SkyHi @ Wednesday, August 26, 2009
Q. I'm using CentOS Linux server with Apache 2 and PHP. I've created .htaccess file for URL rewrting and other configuration options. However, my Apache version 2 .htaccess configuration is not working at all. How do I fix this problem?

Q. .htaccess is Apache's directory-level configuration file. It allows end user to congigure authentication and other options without editing main httpd.conf file.
Make sure AccessFileName set to .htaccess

Search httpd.conf for AccessFileName directive. It defines name of the distributed configuration file:
# grep -i AccessFileName httpd.conf
Make sure users are allowed to use .htaccess file

What you can put in these files is determined by the AllowOverride directive. This directive specifies, in categories, what directives will be honored if they are found in a .htaccess file. If this directive is set to None, then .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem.
# grep -i AllowOverride httpd.conf
When this directive is set to All, then any directive which has the .htaccess Context is allowed in .htaccess files:
AllowOverride ALL
Save and close the file. Restart httpd:
# service httpd restart


<directory "/var/www/html/home.example.com/html">
Order deny, allow
Deny from all
Allow from 192.168.100
</directory>




<directory "/var/www/html/home.example.com/html">
AllowOverride All
</directory>




##Virtualhost Location
Include /etc/httpd/conf/sites



Reference: http://www.cyberciti.biz/faq/apache-htaccess/