.htaccess file and it’s uses
.htaccess files are used to configure apache webservers and few of other web servers. .htaccess file is just a text file that can be edited using any code editor except the fact that it has .htaccess extension.
The .htaccess files will not work on windows based system(IIS servers), having said that it will work on Apache servers. However we can still edit,open,create .htaccess file in windows machine and upload it to the corresponding web applications.
In windows machine we can use the .htaccess file with xampp installed.
A .htaccess file is nothing but a similar to apache’s httpd.conf file. We can configure .htaccess file with all the settings that are being used in httpd.conf file. A setting defined in .htaccess file override the seetings defined in the main configuration file(httpd.conf).
So we can use the .htaccess file for dynamic settings changes for different purposes on different directories.
Having said about dynamic settings let’s see on which cases we need implemt this .htaccess file in production
- To server custom error pages
- Rewriting URL
- To restrict access to files
- Block access to application/files
- To set cache
- To enable compression