Apache Web Server .htaccess File Configuration Not working

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:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 19 comments so far... add one

CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
19 comments… add one
  • webdesign Jun 18, 2008 @ 12:54

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

  • webdesign etten-leur Nov 25, 2008 @ 15:12

    Great tutorial. We use Apache too. thanks

  • Marcos Feb 10, 2010 @ 18:06

    Really thanks buddy. Save my day.

  • jsherk Jun 27, 2010 @ 20:36

    Thanks for this…
    AllowOveride was set to None. changed it to All and now my htaccess files work!

  • anon Nov 5, 2010 @ 12:54

    If it doesn’t work search for more than one occurance of AllowOverride. Drove me mad! Thanx :D

  • Chris Jan 15, 2011 @ 17:24

    This just helped me fix my server. Thanks!

  • selvakumar Jul 13, 2011 @ 6:51

    The htaccess file in ftp where we have to upload( which directory)
    please help me any one.

  • ganesh Aug 31, 2011 @ 16:52


  • Edy Sep 9, 2011 @ 9:51

    Great! Just what I was looking for. Thanks.

  • Hethrir Nov 11, 2011 @ 22:39

    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.


  • Chaim Jan 19, 2012 @ 14:19

    Excellent, just what I needed. Thanks!

  • Kirby Feb 9, 2012 @ 1:35

    Thanks. Short and Sweet.

  • Rao vat Mar 17, 2012 @ 3:49

    Thanks for this..
    cyberciti like

  • Peter Mar 21, 2012 @ 6:53

    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.

  • John Styl Apr 19, 2013 @ 12:26

    AllowOverride ALL That worked for me!
    Thank you for solving my problem

  • sorab Apr 25, 2013 @ 12:47

    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?

  • Stretch Aug 6, 2013 @ 14:36

    Saved my butt in the early hours of the morning. Thank you so much.

  • sandeepm Jan 29, 2015 @ 10:30

    In localhost it working but in server not working why ?

  • Joeyrp Dec 2, 2017 @ 5:48

    Thank you! Turns out AllowOverride None was set in my apache2.conf file.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @ webmaster@cyberciti.biz