In this htaccess tutorial series, you will learn about htaccess configuration and it’s usage.
htaccess refers to Hypertext Access. It is a directory level configuration file, used by Apache Web Server. htaccess file contains set of directives, which is read by Apache web server and apply to the directory on which this file is placed.
In htaccess file, we write Apache directives. So what is directives.Directives is a short
Directives is a short commands used to modify Apache’s behaviour. You can check complete Apache Directives and it’s Meaning.
NOTE – htaccess overrides apache main configuration file (httpd.conf) settings for the directory in which it placed.
Apache Main Configuration File Path
For Febora and CentOS – /etc/httpd/conf/httpd.conf
For Debian and Ubuntu – /etc/apache2/apache2.conf
* In new versions, may be this path differ.
Why htaccess File is Useful
htaccess file is useful when you don’t have a direct access of httpd.conf (Apache configuration) file.
In case of shared hosting, you don’t have a direct access of Apache configuration file (httpd.conf). Take another scenario, suppose you want to host multiple websites on a single server . And also you want to keep different configuration for each website then htaccess file would be ideal for you.
To use htaccess file, you need to enable it first.
htaccess File Usage
1. You can use .htaccess file to create SEO-Friendly URLs.
3. Used for URL redirection.
4. In the case of shared hosting, you can use this file to leverage browser caching.
There are many other amazing things you can do with htaccess file.
NOTE: Always take care while making changes in htaccess file, any error will lead to 500 Internal Server Error.
Does usage of htaccess file slows down website
If you have an access of main configuration file (httpd.conf) then avoid use of htaccess. Using htaccess file slows down Apache HTTP server, which impacts website speed.