2

I was trying to understand .htaccess file. I learned some directives and added them on my htaccess.txt file but things weren't going as I expected. To test whether I put the contents on right file, I rename the htaccess.txt file to .bak. But I am surprised to see that after this change, my site is still running.

I did remember the other day, I tried changing htaccess.txt to .htaccess and my site is getting 500 error. I didn't do anything after that but today my site can run without it. I then move the .htaccess file (which was manually created by me) to another folder, and my site is still working. Could it be cache? I changed to another browser and my mobile, the site is still working! Mystery to me!

Also, on my linux server, /etc/apache2/apache2.conf, there are these lines:

# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

I think this means every folders of every sites on my server use .htaccess. However, on this linux server I have several different Joomla sites, and some of them are using htaccess.txt and the others .htaccess!! Another mystery to me! Why is this?

2

1 Answer 1

2

What is .htaccess?

.htaccess is a configuration file for use on web servers running the Apache Web Server software. When a .htaccess file is placed in a directory which is in turn 'loaded via the Apache Web Server', then the .htaccess file is detected and executed by the Apache Web Server software. These .htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer. These facilities include basic redirect functionality, for instance if a 404 file not found error occurs, or for more advanced functions such as content password protection or image hot link prevention.

http://www.htaccess-guide.com

htaccess.txt that is contained in the joomla installer is not .htaccess - it's only a sample that can be changed to .htaccess, written to work with Joomla. An htaccess.txt is not executed, or doing anything else, it's only a text (.txt) file.

Joomla can work without .htaccess, this is how it is working when first installed. But in order to enable url rewriting (setting in Global Configuration) so that you can rewrite the /index.php urls to those without it, Joomla requires the mod_rewrite and this special rewriting for the index.php, that is written and shipped with the core htaccess.txt. So in this case the .htaccess is required as Joomla relies on it, and that's when Joomla documentation asks to rename the htaccess.txt to .htaccess, otherwise your urls will return 404.

.htaccess is very useful and powerful, as it allows custom configuration of the apache webserver. It can be used to optimize and enhance operations of the server according to the specific needs of a web application. From simple redirections, to file handling, speed enhancements, restrictions and security.

So although for Joomla and generally websites/ web applications the htaccess is optional, its power and the results you can achieve with it makes it a strong recommendation, if not a requirement.

More reading: http://www.askapache.com/category/htaccess/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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