Skip to content

Instantly share code, notes, and snippets.

@hansspiess
Last active May 2, 2020 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hansspiess/a6f1dce1f4a0f0e79826df641c53a49e to your computer and use it in GitHub Desktop.
Save hansspiess/a6f1dce1f4a0f0e79826df641c53a49e to your computer and use it in GitHub Desktop.
Create .htaccess files for standard joomla install to secure folders
# Inside the root directory of the Joomla 3 instance, run these commands to add .htaccess files
# to joomla directories (except ./administrator) that prevent direct access to them.
# Also see https://www.joomla-security.de/dateien-verzeichnisse/htaccess-einstellungen.html
# Generally block access from outside
echo "<Files "*.*">
Deny from all
</Files>" > ./bin/.htaccess; cp -i ./bin/.htaccess ./cache/.htaccess; cp -i ./bin/.htaccess ./cli/.htaccess; cp -i ./bin/.htaccess ./includes/.htaccess; cp -i ./bin/.htaccess ./language/.htaccess; cp -i ./bin/.htaccess ./layouts/.htaccess; cp -i ./bin/.htaccess ./libraries/.htaccess; cp -i ./bin/.htaccess ./logs/.htaccess; cp -i ./bin/.htaccess ./tmp/.htaccess
# Block all except media files: First, create .htaccess file with
<Files "*.*">
Deny from all
</Files>
<FilesMatch "\.(js|css|png|jpg|jpeg|gif|ico|flv|swf|woff|woff2|eot|ttf|pdf|webp)$">
Allow from all
</FilesMatch>
# in ./components/.htaccess
# Then, run
cp -i ./components/.htaccess ./images/.htaccess; cp -i ./components/.htaccess ./media/.htaccess; cp -i ./components/.htaccess ./modules/.htaccess; cp -i ./components/.htaccess ./plugins/.htaccess; cp -i ./components/.htaccess ./templates/.htaccess
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment