Apache .htaccess Security

The cluster discusses web server configurations, particularly Apache's .htaccess files, to prevent exposing sensitive dotfiles like .env and .htaccess due to misconfigurations that allow serving them publicly. Commenters highlight security risks, antipatterns, and best practices for protecting application code from web access.

📉 Falling 0.4x Security
1,981
Comments
20
Years Active
5
Top Authors
#3616
Topic ID

Activity Over Time

2007
6
2008
27
2009
87
2010
93
2011
149
2012
146
2013
180
2014
182
2015
109
2016
71
2017
103
2018
72
2019
88
2020
78
2021
108
2022
129
2023
144
2024
100
2025
105
2026
4

Keywords

e.g PHP TL SERVER CodeIgniter ErrorDocument MAJOR session.save ini.core index.php apache php file web server directory server files html strike config

Sample Comments

rhizome Apr 11, 2018 View on HN

Sounds like the functionality we see configured in e.g. .htaccess files.

wkjagt Jan 29, 2024 View on HN

There are quite a few examples in there of “the bad guy” trying to find files (like .env) that are accidentally left somewhere. From my PHP days I remember that indeed Apache/PHP just serves up any file from anywhere as a static file if it isn’t PHP. My memory is pretty vague on this and I don’t remember if this behaviour is configurable but I guess it must be. Having done mostly Ruby on Rails since, it feels so strange now that a web server can be some kind of a file browser into your code

charcircuit Nov 26, 2022 View on HN

That is an apacheism to avoid serving .htaccess which can include hashed passwords. It's not a general thing.

ilyt Jul 4, 2023 View on HN

Don't let web server access app's code, soo many security problems solved...

BenjiWiebe Nov 26, 2022 View on HN

Are you sure it isn't .ht* that's blocked? That's what the default config is on my system.

DaniloDias Jan 16, 2020 View on HN

TL;DR: Antipattern: pointing web server config to any files based in /home.

nullc Mar 16, 2022 View on HN

HELLO. I FOUND THAT YOUR WEB SERVER HAS DIRECTORY INDEX ENABLED. THIS MAY BE A MAJOR SECURITY INCIDENT.

mattigames Mar 11, 2018 View on HN

You could to that in the server level (not the app level); e.g. in the .htaccess file for apache users.

tmzt May 24, 2013 View on HN

The downloadable distribution of CodeIgniter and many other PHP frameworks have those file and boilerplate to protect badly configured Apache setups where the user just unzips the downloaded distribution into public_html. If you have .php files handled by PHP, or you have the mod rewrite htaccess rules enabled, the PHP files won't be exposed to the user.None of these are necessary if you have properly configured your web server.

known Jun 5, 2017 View on HN

Does Apache web server use this trick?