What is the .htaccess File?
Monday, September 29th, 2008To fully comprehend the .htaccess file and appreciate its usefulness, we first must discuss the main Apache configuration file, called httpd.conf. The httpd.conf file, known simply as the config file, is where the Apache web server’s configuration details are held, including modules, directives, port numbers and other values.. It resides on the administrator’s machine.
Every time an Apache-based web site is loaded, the httpd.conf file is consulted and interpreted. Whenever the file is modified, the administrator restarts (or bounces) the web server, which will compile the httpd.conf file again with the modifications intact.
However, when web servers are built to support outside clients, like a web hosting company’s web servers, administrators do not want clients to have access to the httpd.conf file. If they did, customers could inflict extreme damage on the server. However, at the same time, there are many utilities that customers should have the freedom to explore for their web site.
What is the solution? You guessed it, the .htaccess file. This file is merely an extension to the httpd.conf file; only this time, customers have access to it. Restrictions are placed on the .htaccess file to prevent customers from intentionally or inadvertently damaging default server configurations. Each time an Apache-based web page is loaded, the nearest .htaccess file is consulted and interpreted. The web server does not need to be restarted (or bounced) after each change of the .htaccess file. The file simply needs to be re-uploaded.
Since we now know a little about what the .htaccess file is and what it does, we can examine the magic of the file and look at some typical implementations.
Posted by