Skip to content

Commit

Permalink
enhanced .htaccess files for supporting both Apache 2.2 and 2.4 (#2982)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guite committed Aug 19, 2016
1 parent 3b109c1 commit 598178c
Show file tree
Hide file tree
Showing 15 changed files with 323 additions and 58 deletions.
3 changes: 0 additions & 3 deletions src/.htaccess
Expand Up @@ -2,9 +2,6 @@
# This file is required for short urls to function.
# ----------------------------------------------------------------------

# security options if they work in your environment. If you get a 500 error then they wont.
# These settings are best turned off in php.ini and will be on modern hosting environemnts.

<IfModule mod_rewrite.c>
# Turn the rewriting engine on
RewriteEngine On
Expand Down
28 changes: 25 additions & 3 deletions src/app/.htaccess
@@ -1,5 +1,27 @@
deny from all
# ------------------------------------------------------------------
# Purpose of file: block any web access to unallowed files
# stored under the /app directory
# ------------------------------------------------------------------

# Apache 2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

<FilesMatch "(?i)\.(css|js|jpg|jpeg|gif|png|svg)$">
order allow,deny
allow from all
# Apache 2.2
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</FilesMatch>
16 changes: 14 additions & 2 deletions src/app/cache/.htaccess
@@ -1,2 +1,14 @@
Order deny,allow
deny from all
# ------------------------------------------------------------------
# Purpose of file: block any web access to unallowed files
# stored under the /app/cache directory
# ------------------------------------------------------------------

# Apache 2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
16 changes: 14 additions & 2 deletions src/app/logs/.htaccess
@@ -1,2 +1,14 @@
Order deny,allow
deny from all
# ------------------------------------------------------------------
# Purpose of file: block any web access to unallowed files
# stored under the /app/logs directory
# ------------------------------------------------------------------

# Apache 2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
30 changes: 26 additions & 4 deletions src/config/.htaccess
@@ -1,5 +1,27 @@
deny from all
# ------------------------------------------------------------------
# Purpose of file: block any web access to unallowed files
# stored under the /config directory
# ------------------------------------------------------------------

# Apache 2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

<FilesMatch "(?i)\.(css|js|png|gif|jpg|jpeg|bmp)$">
order allow,deny
allow from all
</filesmatch>
# Apache 2.2
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</FilesMatch>
32 changes: 27 additions & 5 deletions src/javascript/.htaccess
@@ -1,5 +1,27 @@
deny from all
<FilesMatch "(?i)\.(css|js|jpg|jpeg|gif|png)$">
order allow,deny
allow from all
</filesmatch>
# ------------------------------------------------------------------
# Purpose of file: block any web access to unallowed files
# stored under the /javascript directory
# ------------------------------------------------------------------

# Apache 2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

<FilesMatch "(?i)\.(css|gif|jpg|jpeg|js|png)$">
# Apache 2.2
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</FilesMatch>
16 changes: 14 additions & 2 deletions src/lib/.htaccess
@@ -1,2 +1,14 @@
Order deny,allow
Deny from all
# ------------------------------------------------------------------
# Purpose of file: block any web access to unallowed files
# stored under the /lib directory
# ------------------------------------------------------------------

# Apache 2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
27 changes: 24 additions & 3 deletions src/modules/.htaccess
@@ -1,6 +1,27 @@
Deny from all
# ------------------------------------------------------------------
# Purpose of file: block any web access to unallowed files
# stored under the /modules directory
# ------------------------------------------------------------------

# Apache 2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

<FilesMatch "(?i)\.(css|css\.map|eot|flv|gif|ico|jpeg|jpg|js|map|mp4|ogv|pdf|png|svg|swf|ttf|webm|woff)$">
Order Allow,Deny
Allow from all
# Apache 2.2
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</FilesMatch>
30 changes: 26 additions & 4 deletions src/plugins/.htaccess
@@ -1,5 +1,27 @@
deny from all
<FilesMatch "(?i)\.(css|js|png|gif|jpg|jpeg|swf)$">
order allow,deny
allow from all
# ------------------------------------------------------------------
# Purpose of file: block any web access to unallowed files
# stored under the /plugins directory
# ------------------------------------------------------------------

# Apache 2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

<FilesMatch "(?i)\.(css|js|gif|jpg|jpeg|png|swf)$">
# Apache 2.2
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</FilesMatch>
32 changes: 25 additions & 7 deletions src/plugins/Imagine/templates/default.htaccess
@@ -1,9 +1,27 @@
# ----------------------------------------------------------------------
# Purpose of file: block any web access to not allowed files
# ------------------------------------------------------------------
# Purpose of file: block any web access to unallowed files
# stored under the imagine thumbnails directory
# ----------------------------------------------------------------------
deny from all
# ------------------------------------------------------------------

# Apache 2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

<FilesMatch "(?i)\.(png|gif|jpg|jpeg)$">
order allow,deny
allow from all
</filesmatch>
# Apache 2.2
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</FilesMatch>
36 changes: 27 additions & 9 deletions src/style/.htaccess
@@ -1,9 +1,27 @@
# ----------------------------------------------------------------------
# Purpose of file: block any web access to files stored under
# the style/ directory
# ----------------------------------------------------------------------
deny from all
<FilesMatch "\.(css)$">
order allow,deny
allow from all
</filesmatch>
# ------------------------------------------------------------------
# Purpose of file: block any web access to unallowed files
# stored under the /style directory
# ------------------------------------------------------------------

# Apache 2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

<FilesMatch "(?i)\.(css|gif)$">
# Apache 2.2
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</FilesMatch>
30 changes: 26 additions & 4 deletions src/system/.htaccess
@@ -1,5 +1,27 @@
deny from all
<FilesMatch "(?i)\.(css|css\.map|js|jpg|jpeg|gif|png)$">
order allow,deny
allow from all
# ------------------------------------------------------------------
# Purpose of file: block any web access to unallowed files
# stored under the /system directory
# ------------------------------------------------------------------

# Apache 2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

<FilesMatch "(?i)\.(css|css\.map|gif|jpg|jpeg|js|png)$">
# Apache 2.2
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</FilesMatch>
27 changes: 24 additions & 3 deletions src/themes/.htaccess
@@ -1,6 +1,27 @@
Deny from all
# ------------------------------------------------------------------
# Purpose of file: block any web access to unallowed files
# stored under the /themes directory
# ------------------------------------------------------------------

# Apache 2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

<FilesMatch "(?i)\.(css|eot|flv|gif|ico|jpeg|jpg|js|map|mp4|ogv|pdf|png|svg|swf|ttf|webm|woff)$">
Order Allow,Deny
Allow from all
# Apache 2.2
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</FilesMatch>
30 changes: 26 additions & 4 deletions src/userdata/.htaccess
@@ -1,5 +1,27 @@
deny from all
# ------------------------------------------------------------------
# Purpose of file: block any web access to unallowed files
# stored under the /userdata directory
# ------------------------------------------------------------------

# Apache 2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

<FilesMatch "(?i)\.(css|js|rss|png|gif|jpg|jpeg|psd|svg|txt|rtf|xml|pdf|sdt|odt|doc|docx|pps|ppt|pptx|xls|xlsx|mp3|wav|wma|avi|flv|mov|mp4|rm|vob|wmv|gz|rar|tar.gz|zip)$">
order allow,deny
allow from all
</filesmatch>
# Apache 2.2
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</FilesMatch>

0 comments on commit 598178c

Please sign in to comment.