This guide explains how to restrict the public from viewing files such as .htaccess, .htpasswd, .ini, .phps, .fla, .psd, .log, and .sh from visiting the URL of the file by modifying the .htaccess file.
Related Articles
Password Protect Directory in cPanel
Block or Allow Specific IP via .htaccess
Block User Agent with .htaccess
Modifying the .htaccess
- Login to cPanel
- Navigate to the File Manager
- Locate the
.htaccessfile in the Document Root of the domain
TIP: If .htaccess is not present, show hidden files in File Manager. - Edit the
.htaccessfile - Place the following code into the
.htaccess:
<filesMatch ".(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
Order Allow,Deny
Deny from all
</filesMatch>NOTE: The parameters
htaccess|htpasswd|ini|phps|fla|psd|log|shin the code will restrict anyone trying to see the following file types:
.htaccess
.htpasswd
.ini
.phps
.fla
.psd
.log
.sh