Chris@0
|
1 #
|
Chris@0
|
2 # Apache/PHP/Drupal settings:
|
Chris@0
|
3 #
|
Chris@0
|
4
|
Chris@0
|
5 # Protect files and directories from prying eyes.
|
Chris@0
|
6 <FilesMatch "\.(engine|inc|install|make|module|profile|po|sh|.*sql|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock))$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$">
|
Chris@0
|
7 <IfModule mod_authz_core.c>
|
Chris@0
|
8 Require all denied
|
Chris@0
|
9 </IfModule>
|
Chris@0
|
10 <IfModule !mod_authz_core.c>
|
Chris@0
|
11 Order allow,deny
|
Chris@0
|
12 </IfModule>
|
Chris@0
|
13 </FilesMatch>
|
Chris@0
|
14
|
Chris@0
|
15 # Don't show directory listings for URLs which map to a directory.
|
Chris@0
|
16 Options -Indexes
|
Chris@0
|
17
|
Chris@0
|
18 # Set the default handler.
|
Chris@0
|
19 DirectoryIndex index.php index.html index.htm
|
Chris@0
|
20
|
Chris@0
|
21 # Add correct encoding for SVGZ.
|
Chris@0
|
22 AddType image/svg+xml svg svgz
|
Chris@0
|
23 AddEncoding gzip svgz
|
Chris@0
|
24
|
Chris@0
|
25 # Most of the following PHP settings cannot be changed at runtime. See
|
Chris@0
|
26 # sites/default/default.settings.php and
|
Chris@0
|
27 # Drupal\Core\DrupalKernel::bootEnvironment() for settings that can be
|
Chris@0
|
28 # changed at runtime.
|
Chris@0
|
29
|
Chris@0
|
30 # PHP 5, Apache 1 and 2.
|
Chris@0
|
31 <IfModule mod_php5.c>
|
Chris@0
|
32 php_value assert.active 0
|
Chris@0
|
33 php_flag session.auto_start off
|
Chris@0
|
34 php_value mbstring.http_input pass
|
Chris@0
|
35 php_value mbstring.http_output pass
|
Chris@0
|
36 php_flag mbstring.encoding_translation off
|
Chris@0
|
37 # PHP 5.6 has deprecated $HTTP_RAW_POST_DATA and produces warnings if this is
|
Chris@0
|
38 # not set.
|
Chris@0
|
39 php_value always_populate_raw_post_data -1
|
Chris@0
|
40 </IfModule>
|
Chris@0
|
41
|
Chris@0
|
42 # Requires mod_expires to be enabled.
|
Chris@0
|
43 <IfModule mod_expires.c>
|
Chris@0
|
44 # Enable expirations.
|
Chris@0
|
45 ExpiresActive On
|
Chris@0
|
46
|
Chris@0
|
47 # Cache all files for 2 weeks after access (A).
|
Chris@0
|
48 ExpiresDefault A1209600
|
Chris@0
|
49
|
Chris@0
|
50 <FilesMatch \.php$>
|
Chris@0
|
51 # Do not allow PHP scripts to be cached unless they explicitly send cache
|
Chris@0
|
52 # headers themselves. Otherwise all scripts would have to overwrite the
|
Chris@0
|
53 # headers set by mod_expires if they want another caching behavior. This may
|
Chris@0
|
54 # fail if an error occurs early in the bootstrap process, and it may cause
|
Chris@0
|
55 # problems if a non-Drupal PHP file is installed in a subdirectory.
|
Chris@0
|
56 ExpiresActive Off
|
Chris@0
|
57 </FilesMatch>
|
Chris@0
|
58 </IfModule>
|
Chris@0
|
59
|
Chris@0
|
60 # Set a fallback resource if mod_rewrite is not enabled. This allows Drupal to
|
Chris@0
|
61 # work without clean URLs. This requires Apache version >= 2.2.16. If Drupal is
|
Chris@0
|
62 # not accessed by the top level URL (i.e.: http://example.com/drupal/ instead of
|
Chris@0
|
63 # http://example.com/), the path to index.php will need to be adjusted.
|
Chris@0
|
64 <IfModule !mod_rewrite.c>
|
Chris@0
|
65 FallbackResource /index.php
|
Chris@0
|
66 </IfModule>
|
Chris@0
|
67
|
Chris@0
|
68 # Various rewrite rules.
|
Chris@0
|
69 <IfModule mod_rewrite.c>
|
Chris@0
|
70 RewriteEngine on
|
Chris@0
|
71
|
Chris@0
|
72 # Set "protossl" to "s" if we were accessed via https://. This is used later
|
Chris@0
|
73 # if you enable "www." stripping or enforcement, in order to ensure that
|
Chris@0
|
74 # you don't bounce between http and https.
|
Chris@0
|
75 RewriteRule ^ - [E=protossl]
|
Chris@0
|
76 RewriteCond %{HTTPS} on
|
Chris@0
|
77 RewriteRule ^ - [E=protossl:s]
|
Chris@0
|
78
|
Chris@0
|
79 # Make sure Authorization HTTP header is available to PHP
|
Chris@0
|
80 # even when running as CGI or FastCGI.
|
Chris@0
|
81 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
Chris@0
|
82
|
Chris@0
|
83 # Block access to "hidden" directories whose names begin with a period. This
|
Chris@0
|
84 # includes directories used by version control systems such as Subversion or
|
Chris@0
|
85 # Git to store control files. Files whose names begin with a period, as well
|
Chris@0
|
86 # as the control files used by CVS, are protected by the FilesMatch directive
|
Chris@0
|
87 # above.
|
Chris@0
|
88 #
|
Chris@0
|
89 # NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is
|
Chris@0
|
90 # not possible to block access to entire directories from .htaccess because
|
Chris@0
|
91 # <DirectoryMatch> is not allowed here.
|
Chris@0
|
92 #
|
Chris@0
|
93 # If you do not have mod_rewrite installed, you should remove these
|
Chris@0
|
94 # directories from your webroot or otherwise protect them from being
|
Chris@0
|
95 # downloaded.
|
Chris@0
|
96 RewriteRule "/\.|^\.(?!well-known/)" - [F]
|
Chris@0
|
97
|
Chris@0
|
98 # If your site can be accessed both with and without the 'www.' prefix, you
|
Chris@0
|
99 # can use one of the following settings to redirect users to your preferred
|
Chris@0
|
100 # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
|
Chris@0
|
101 #
|
Chris@0
|
102 # To redirect all users to access the site WITH the 'www.' prefix,
|
Chris@0
|
103 # (http://example.com/foo will be redirected to http://www.example.com/foo)
|
Chris@0
|
104 # uncomment the following:
|
Chris@0
|
105 # RewriteCond %{HTTP_HOST} .
|
Chris@0
|
106 # RewriteCond %{HTTP_HOST} !^www\. [NC]
|
Chris@0
|
107 # RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
Chris@0
|
108 #
|
Chris@0
|
109 # To redirect all users to access the site WITHOUT the 'www.' prefix,
|
Chris@0
|
110 # (http://www.example.com/foo will be redirected to http://example.com/foo)
|
Chris@0
|
111 # uncomment the following:
|
Chris@0
|
112 # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
|
Chris@0
|
113 # RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
|
Chris@0
|
114
|
Chris@0
|
115 # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
|
Chris@0
|
116 # VirtualDocumentRoot and the rewrite rules are not working properly.
|
Chris@0
|
117 # For example if your site is at http://example.com/drupal uncomment and
|
Chris@0
|
118 # modify the following line:
|
Chris@0
|
119 # RewriteBase /drupal
|
Chris@0
|
120 #
|
Chris@0
|
121 # If your site is running in a VirtualDocumentRoot at http://example.com/,
|
Chris@0
|
122 # uncomment the following line:
|
Chris@0
|
123 # RewriteBase /
|
Chris@0
|
124
|
Chris@0
|
125 # Redirect common PHP files to their new locations.
|
Chris@0
|
126 RewriteCond %{REQUEST_URI} ^(.*)?/(install.php) [OR]
|
Chris@0
|
127 RewriteCond %{REQUEST_URI} ^(.*)?/(rebuild.php)
|
Chris@0
|
128 RewriteCond %{REQUEST_URI} !core
|
Chris@0
|
129 RewriteRule ^ %1/core/%2 [L,QSA,R=301]
|
Chris@0
|
130
|
Chris@0
|
131 # Rewrite install.php during installation to see if mod_rewrite is working
|
Chris@0
|
132 RewriteRule ^core/install.php core/install.php?rewrite=ok [QSA,L]
|
Chris@0
|
133
|
Chris@0
|
134 # Pass all requests not referring directly to files in the filesystem to
|
Chris@0
|
135 # index.php.
|
Chris@0
|
136 RewriteCond %{REQUEST_FILENAME} !-f
|
Chris@0
|
137 RewriteCond %{REQUEST_FILENAME} !-d
|
Chris@0
|
138 RewriteCond %{REQUEST_URI} !=/favicon.ico
|
Chris@0
|
139 RewriteRule ^ index.php [L]
|
Chris@0
|
140
|
Chris@0
|
141 # For security reasons, deny access to other PHP files on public sites.
|
Chris@0
|
142 # Note: The following URI conditions are not anchored at the start (^),
|
Chris@0
|
143 # because Drupal may be located in a subdirectory. To further improve
|
Chris@0
|
144 # security, you can replace '!/' with '!^/'.
|
Chris@0
|
145 # Allow access to PHP files in /core (like authorize.php or install.php):
|
Chris@0
|
146 RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
|
Chris@0
|
147 # Allow access to test-specific PHP files:
|
Chris@0
|
148 RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php
|
Chris@0
|
149 # Allow access to Statistics module's custom front controller.
|
Chris@0
|
150 # Copy and adapt this rule to directly execute PHP files in contributed or
|
Chris@0
|
151 # custom modules or to run another PHP application in the same directory.
|
Chris@0
|
152 RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$
|
Chris@0
|
153 # Deny access to any other PHP files that do not match the rules above.
|
Chris@0
|
154 # Specifically, disallow autoload.php from being served directly.
|
Chris@0
|
155 RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]
|
Chris@0
|
156
|
Chris@0
|
157 # Rules to correctly serve gzip compressed CSS and JS files.
|
Chris@0
|
158 # Requires both mod_rewrite and mod_headers to be enabled.
|
Chris@0
|
159 <IfModule mod_headers.c>
|
Chris@0
|
160 # Serve gzip compressed CSS files if they exist and the client accepts gzip.
|
Chris@0
|
161 RewriteCond %{HTTP:Accept-encoding} gzip
|
Chris@0
|
162 RewriteCond %{REQUEST_FILENAME}\.gz -s
|
Chris@0
|
163 RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
|
Chris@0
|
164
|
Chris@0
|
165 # Serve gzip compressed JS files if they exist and the client accepts gzip.
|
Chris@0
|
166 RewriteCond %{HTTP:Accept-encoding} gzip
|
Chris@0
|
167 RewriteCond %{REQUEST_FILENAME}\.gz -s
|
Chris@0
|
168 RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
|
Chris@0
|
169
|
Chris@0
|
170 # Serve correct content types, and prevent mod_deflate double gzip.
|
Chris@0
|
171 RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
|
Chris@0
|
172 RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
|
Chris@0
|
173
|
Chris@0
|
174 <FilesMatch "(\.js\.gz|\.css\.gz)$">
|
Chris@0
|
175 # Serve correct encoding type.
|
Chris@0
|
176 Header set Content-Encoding gzip
|
Chris@0
|
177 # Force proxies to cache gzipped & non-gzipped css/js files separately.
|
Chris@0
|
178 Header append Vary Accept-Encoding
|
Chris@0
|
179 </FilesMatch>
|
Chris@0
|
180 </IfModule>
|
Chris@0
|
181 </IfModule>
|
Chris@0
|
182
|
Chris@0
|
183 # Various header fixes.
|
Chris@0
|
184 <IfModule mod_headers.c>
|
Chris@0
|
185 # Disable content sniffing, since it's an attack vector.
|
Chris@0
|
186 Header always set X-Content-Type-Options nosniff
|
Chris@0
|
187 # Disable Proxy header, since it's an attack vector.
|
Chris@0
|
188 RequestHeader unset Proxy
|
Chris@0
|
189 </IfModule>
|