This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
oliverdavies.uk-old-sculpin/source/_posts/prevent-apache-displaying-text-files-within-web-browser.md

31 lines
938 B
Markdown
Raw Normal View History

2015-03-16 21:18:03 +00:00
---
title: Prevent Apache from displaying text files within a web browser
2020-03-08 14:32:13 +00:00
date: 2012-05-23
excerpt:
How to prevent Apache from displaying the contents of files like
CHANGELOG.txt.
2015-03-16 21:18:03 +00:00
tags:
2015-06-14 02:27:41 +00:00
- apache
- code
- drupal
2015-03-16 21:18:03 +00:00
---
2015-06-18 07:58:56 +00:00
When you download [Drupal](http://drupal.org/project/drupal), there are several
text files that are placed in the root of your installation. You don't want or
need these to be visible to anyone attempting to view them in a browser -
especially CHANGELOG.txt as that includes the exact version of Drupal you are
running and could therefore have security implications.
Rather than delete these files or change the file permissions manually for each
file, I can add the following lines into my VirtualHost configuration.
2015-06-18 07:58:56 +00:00
2017-03-16 08:09:52 +00:00
```language-apacheconf
<Files ~ "\.txt$">
Order deny,allow
Deny from all
</Files>
```
2015-03-16 21:18:03 +00:00
This prevents any files with a .txt extension from being accessed and rendered
in a web browser.