Menu Close


.htaccess is short for Hypertext Access, and is a configuration file used by Apache-based web servers that controls the directory that it “lives” in–as well as all the subdirectories underneath that directory. Also helps to create Custom Error Pages for Better SEO.

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.

You can create the .htaccess file in a text editor (make sure to name it only .htaccess without any other extension or name) and then upload it to your site through an ftp client. You can also create .html file in your File manager and create an file, and then name that file as .htaccess

Additionally the placement of the .htaccess file is important. The configurations in that file will affect everything in its directory and the directories under it.

What is the basic usages of htaccess file ?

How to Specify File Size Limit and Max Execution Time Limit for PHP using htaccess file

How to Implement a Caching Scheme with htaccess file

How to make 301 Redirect Using htaccess File

How to Make Scripts Display as Source Codes Using htaccess file ?

How to Modify Environment Variable by htaccess file

How to Prevent Access to Your php.ini file or any other risky files by htaccess file

How to Prevent Access to Your php includes files by htaccess file ?

How to Disable Server Signature by htaccess file ?

How to Set Your Website Timezone by htacess file

How to Pretect Your WordPress Website wp-admin folder and wp-login.php file using .htaccess file ?

How to Prevent Dir Listings or Show FancyIndex by htaccess file

How to Change Your Website Root Directory with .htaccess file

How to Prevent PHP, Perl Executable scripts Run in your Image Folder with .htaccess file

How to redirect Http to Https Using .htaccess file

How to Run Your CGI Scripts outside CGI-BIN folder by .htaccess file

How to enable Server Side Include (SSI) with .htaccess file

Adding MIME Types by .htaccess file

How to Change the default Directory Index in Apache Server by .htaccess file ?

How to Block Bad Bots, Site Rippers, Crawlers, Scrapers and Malwares by .htaccess file

How to Hot Link Protect Your Files by .htaccess File

How to Block Visitors from Spam Referrers By .htaccess file

Password Protect A Directory or A Single File by the .htaccess file

Custom Error Responses by .htaccess ErrorDocuments following HTTP response status codes

How to Redirect By .htaccess File ?

How to deny IP addresses by .htaccess

How to Instruct Browser to Download Media Files Instead of Display Them Using htaccess file

How to Prevent Requests with Invalid Characters Using htaccess file

The Disadvantages of .htaccess file

1. The slower speed and permision loss: The .htaccess file may slow down your server speed.   If .htaccess files are allowed (via the AllowOverride directive) then apache will look for .htaccess files on every request.  In addition, Apache has to look up the directory tree to see if there are further .htaccess files in locations above the location the file is requested from so that it can tell which directives have precedence. Each time a page loads, the server scans its directory, and any above it until it reaches the highest directory or an .htaccess file. A lot of wordpress cache plugins avoid using .htaccess files because of its httpd slower disadvantage.

2. The high risk Security:  Not the administrator but all users can modify their own apache configuration files. Allowing individual users to modify the configuration of a server using .htaccess can cause security concerns if not taken care properly.  The .htaccess file is much more accessible than standard apache configuration and the changes are made live instantly (without the need to restart the server). Granting users permission to make alterations in the .htaccess file gives them a lot of control over the server itself.  Any directive placed in the .htaccess file, has the same effect as it would in the apache configuration itself.

The Advantage of .htaccess file

1. Immediate changes without restarting httpd server:  any change in Apache configuration(httpd.conf) file need to restart the httpd apache server  to take effect. By using .htaccess file, we can configure features of Apache and these changes will get reflect immediately because .htaccess files are read on every request by Apache Web Server software.

2. Not just administrator but all Non-privileged users can configure their own applications : As we know that Apache configuration file httpd.conf is only accessible and managed by administrator. It  is not accessible or manageable by normal users.  Now, a normal user can use .htaccess file to configure Apache configurations for their own application as per their need. Hence, main Apache configurations are still same for other application running on the web server.