Skip to main content

What is .htaccess file ?

Hello guys,
Welcome to Tech Master Forum.....
Today we are going to learn about ".htaccess file".


If you go through this article, You will get clarification about how it works on web server and all...
Actually, i have gone through many of the websites, and now finally, created one conceptual blog for you guys...
I hope, it will helpful for your knowledge base purpose....

Firstly, i would like tell you that, Actually, It's not part of the PHP Programming Language;
it's just part of Apache Framework.

Introduction to .htaccess file



Overview

.htaccess file


The .htaccess file is a simple text file with the name .htaccess. 

.htaccess is a file which always executes before every request on your domain/ webserver. Basically this file is located at the root folder of your domain structure, htaccess (hypertext access) is a useful file for Many of web server to apply settings per directory basis.  It allows to override default configuration for your web based application. 

A .htaccess file is a way to configure the details of your website without needed to alter the server config files as well as it allows you to control the behavior of the Apache web server through safe and simple customization. .htaccess is short for Hypertext Access. It is a configuration file used by apache-based web servers. Configuration files configure the initial settings of a program, or in this case the server.  That means that the .htaccess file can be used to make the server behave in a certain way. 

Each function is basically just a line of text, or code, which tells the server what to do. 
You can add or change functionality by adding or changing the code in the .htaccess file.
An .htaccess file is a directory-level configuration file supported by several web servers, used for configuration of website-access issues, such as URL redirection, URL shortening, access control, and more.  The 'dot' before the file name makes it a hidden file in Unix-based environments..


Below you can see, you can disable apache web directory listing by using .htaccess file


Apache Web Directory Listing


*In short, every website having it's own initial web settings or configuration then this is the file "which you are looking for" *


What is htaccess file ?


.htaccess is basically root file for every website, which maintains all configuration information related to website. 

.htaccess is the default name for a file that is used to indicate who can or cannot access the contents of a specific file directory from the Internet resources online. The .htaccess file is a configuration file that resides in a directory and indicates which users or groups of users can be allowed access to the files contained in that directory. .htaccess is a shortened version of “hypertext access.” 

It's the file that helps to control the behavior of your web server. .htaccess files provide a way to make configuration changes on a per-directory basis. Essentially, it allows you to take directives that would normally be put in Apache's main configuration files, and put them in a directory-specific configuration file instead. .htaccess is a configuration file for use on web servers running the Apache Web Server software

What is htaccess file ?


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.

Whenever any request is sent to the server it always passes through .htaccess file. There are some rules are defined to instruct the working. They're mostly used in cases where you don't have access to the main configuration files (e.g. a shared host). htaccess is short for Hypertext Access. It is a configuration file used by apache-based web servers. htaccess is a configuration file for use on web servers running the Apache Web Server software. When a .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.


History of .htaccess ?


.htaccess was introduced as a directory-level, user authentication method along with the original programs developed for retrieving Web pages over the Internet, such as Hypertext Transfer Protocol daemon


History of .htaccess file


When users type in a Uniform Resource Locator (the name of a Web site they want to go to), the URL begins with "http://". This command is recognized by the underlying Web server software program, HTTPd (for HyperText Transfer Protocol daemon).  (A daemon is a program that sits waiting for requests for other programs.)


Use of .htaccess file ?


There are a lot of possibilities with .htaccess, you can, for example, use it to:

1. Secure your website with a password authentication.
2. Creation of custom error message like 404 Error Page
3. Redirection for visitors to another custom url or any page.
4. Rewriting url's (Servers often use .htaccess to rewrite "ugly" URLs to shorter and prettier ones.)
5. It's allows the user to control User agent caching used by web browsers to reduce bandwidth usage, server load, and perceived lag.
6. Customized Error Message (Changing the page that is shown when a server-side error occurs, for example HTTP 404 Not Found.)
7. htaccess is a very powerful tool. To avoid that you could break your site by accident, we have disabled certain functions. 

use of htaccess file



Whether Use or Not to use .htaccess file ?


.htaccess is often used in settings where a group network administrator wants to control who views or changes the contents of the directories that relate to his or her groups or users. In these settings, it is not practical or advisable to give the administrator primary access to all of the HTTPd server's functions, and all of its other directories and configuration files. Having the local-level control provided by .htaccess files allows more flexibility for the administrator to create and change directory access controls, as needed.

Some disadvantages to using .htaccess files have been noted: If an organization has several hundred .htaccess files on several hundred directories, each granting or denying user access to their own contents, it is more difficult for the company's network administrators to prepare a global access or authentication strategy and keep up with changes. Also, .htaccess files can be overwritten very easily, causing problems for users who once could access a directory's contents, but now cannot. Finally, .htaccess files are more likely to be opened or retrieved by unauthorized users.


"On next part of session, we will learn about how we are going access and edit .htaccess file"


References:

https://www.tutorialspoint.com/what-is-htaccess-in-php
https://ithemes.com/what-is-the-htaccess-file/
https://www.htmlgoodies.com/beyond/webmaster/article.php/3899416/What-is-the-htaccess-File-and-What-Can-I-Do-With-It.htm
https://www.wpbeginner.com/glossary/htaccess/
https://themeisle.com/blog/htaccess-file-in-wordpress/
https://help.one.com/hc/en-us/articles/115005586169-What-is-htaccess-

Conclusion:


From this blog, you’ve learned that, what is the use of .htaccess file as well as it's major functionality like to create website redirection, set cache statement, set timezone, set other user privileges, set default pages, password-protect directories, authentication and much more.


(Note: This article is only for educational information purpose, it's not intentional to take anyone's credit and their useful efforts. Our main motto is to share passionate knowledge to the all technology enthusiasts with an opportunity to gain more knowledge....)



Comments

Post a Comment

Popular posts from this blog

What is Backlinks ?

In this article , you will learn basics of  backlinks , and their uses in day to day life. In your SEO life , one mode came, in that you have to do with  backlinks submission activities for your website to many of the high authority destination websites for the purpose of higher ranking . Firstly, we'll learn,   Why back-links are so important for ranking purpose ?   Then, it's use and all.... Backlinks are the links of your website (hyperlink) into any other destination website (into source code), like suppose you're website domain name is the rbtechservices.in then this hyperlink code is reside in any other destination website source code's (in backend) like let's say tablabs.in (it's your destination website). <a href="https://www.rbtechse...

Latest IT General Quiz Question (2020)

  Latest IT General Quiz (2020)  If you want to become master in your area , then you must have passionate knowledge about each and everything, which will help you grow up your development skills as well as interview skills .      Technical Master is an online virtual platform which is open for technical discussion for the technology enthusiasts with an opportunity to hold more accurate knowledge and to know more about current affairs regarding the same...  Let's initiate and participate with techni...