What is .htaccess and why do we use it?

.htaccess (hypertext access) is a configuration file of the Apache web server. You can put it in any folder of your website, and the rules inside it apply to that folder and its sub-folders. The big benefit is that you can change server settings without touching the main server configuration.

Common uses of .htaccess:

# Stop showing the list of files of a folder
Options -Indexes
Note: .htaccess works only on Apache (and compatible servers like LiteSpeed). Nginx does not read it. A wrong rule can break your site with a 500 error, so always take a backup of the file before you edit it.

Learn more about the similar topics:
Tutorials
PHP Introduction
PHP Terminology
PHP Installation
PHP Syntax
PHP Comments
PHP exit() Function
Exercises & Assignments
Write a program to print “Hello World” using echo
Simple Tips for PHP Beginners
Experiment with Basic PHP Syntax Errors
Using phpinfo() – Display PHP Configuration & Modules
Interview Questions & Answers
What is PHP?
Who is the father of PHP?
What is the correct & common way to start and finish a PHP block of code?
What is Open Source Software?
What is the default extension of the PHP file?
What is the latest version of PHP?
What is the full form of PHP?