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:
🐧 19 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
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 :)
Great tutorial. We use Apache too. thanks
Really thanks buddy. Save my day.
Thanks for this…
AllowOveride was set to None. changed it to All and now my htaccess files work!
If it doesn’t work search for more than one occurance of AllowOverride. Drove me mad! Thanx :D
This just helped me fix my server. Thanks!
The htaccess file in ftp where we have to upload( which directory)
please help me any one.
Thanks
Great! Just what I was looking for. Thanks.
Spelling error:
“congigure”
Excellent, just what I needed. Thanks!
Thanks. Short and Sweet.
Thanks for this..
cyberciti like
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.
AllowOverride ALL That worked for me!
Thank you for solving my problem
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?
Saved my butt in the early hours of the morning. Thank you so much.
In localhost it working but in server not working why ?
Thank you! Turns out AllowOverride None was set in my apache2.conf file.