If you’re using Apache web server, this is the first and basic step to protect your web application using .htaccess file.
create and put the .htaccess file in root folder of your application and write the code;
# Protect the files that important and contain sensitive information such as database username and password
Order allow,deny
Deny from all
# Protect .htaccess files it self
Order allow,deny
Deny from all
# protect development folder and files
Order deny,allow
Allow from xx.xx.xx.xx
Deny from all
# Rules to disable directory browsing
Options -Indexes