Knowledgebase

Bloquear acceso a archivos con htaccess

Vamos a ver varios ejemplos de cómo impedir el acceso a archivos de nuestro servidor.

Por ejemplo, si al intentar acceder a http://www.tudominio.com/.htaccess no recibes un “Forbidden“, significa que este tipo de archivos no están protegidos contra el acceso en la configuración de tu servidor. Para solucionarlo, edita (si ya existe) o crea un archivo .htaccess en el directorio raíz de tu espacio web con las siguientes líneas en su interior:

<Files .htaccess>
Order allow,deny
Deny from all
</Files>


De la misma forma puedes bloquear el acceso a cualquier otro archivo:

<Files archivosecreto.txt>
Order allow,deny
Deny from all
</Files>

Nota: esto afectaría a cualquier archivo con el nombre “archivosecreto.txt” que se encuentre en el servidor.


Además, usando la directiva FilesMatch, puedes proteger archivos con determinadas extensiones:

<FilesMatch "\.(htaccess|htpasswd|ini|phps|log|bak|txt)$">
Order Allow,Deny
Deny from all
</FilesMatch>

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Prestashop update

Update Prestashop To update Prestashop to the new version, the following steps will be carried...

Viruses on the web. Help!!! What are they and how do we eliminate them?

Lately, cases of websites that are infected by viruses or malicious code, without the webmaster...

How can I manage the domain?

For everything related to the administration of your domain, you must use the CPANEL control...

What is a subdomain?

Subdomains are extensions that we can use with our domain, for example, suppose that our domain...

How to publish my website?

To upload the content of your website to the server you can use any FTP client such as FileZilla,...