Apache Web Server .htaccess File Configuration Not working

Posted on in Categories , , , , last updated August 23, 2012

I‘m using a CentOS Linux server with Apache 2 web-server 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?

.htaccess is Apache’s directory-level configuration file. It allows end user to configure 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

See also:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

18 comment

  1. Well i tried that with apache2 but i only found a AllowOverride None wich is uncommented! and httpd.con seems te be apache2.conf … maybe a little help would be nice :)

  2. Spelling error:

    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.

    “congigure”

  3. I changed from one server to another and when i upload the .htacess file, i can’t bowse the webiste. When I remove the .htacess file, I can access the site but not the idex file or fomrs. Anyone who can assist me resolve this problem. Thank you.

  4. Hi, I have a joomla website under construction and I have uploaded it , but it does not work, my problem is that the .htaccess is not showing error so I can understand the source of the failure. does anyone know why?

Leave a Comment