29b5b86 by Anon Ray at 2013-10-03 1
# Apache Server Configs v1.1.0 | MIT License
2
# https://github.com/h5bp/server-configs-apache
3ce3fe9 by Anon Ray at 2012-11-23 3
29b5b86 by Anon Ray at 2013-10-03 4
# (!) Using `.htaccess` files slows down Apache, therefore, if you have access
5
# to the main server config file (usually called `httpd.conf`), you should add
6
# this logic there: http://httpd.apache.org/docs/current/howto/htaccess.html.
3ce3fe9 by Anon Ray at 2012-11-23 7
29b5b86 by Anon Ray at 2013-10-03 8
# ##############################################################################
9
# # CROSS-ORIGIN RESOURCE SHARING (CORS)                                       #
10
# ##############################################################################
3ce3fe9 by Anon Ray at 2012-11-23 11
29b5b86 by Anon Ray at 2013-10-03 12
# ------------------------------------------------------------------------------
13
# | Cross-domain AJAX requests                                                 |
14
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 15
29b5b86 by Anon Ray at 2013-10-03 16
# Enable cross-origin AJAX requests.
17
# http://code.google.com/p/html5security/wiki/CrossOriginRequestSecurity
18
# http://enable-cors.org/
3ce3fe9 by Anon Ray at 2012-11-23 19
29b5b86 by Anon Ray at 2013-10-03 20
# <IfModule mod_headers.c>
3ce3fe9 by Anon Ray at 2012-11-23 21
#    Header set Access-Control-Allow-Origin "*"
29b5b86 by Anon Ray at 2013-10-03 22
# </IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 23
29b5b86 by Anon Ray at 2013-10-03 24
# ------------------------------------------------------------------------------
25
# | CORS-enabled images                                                        |
26
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 27
29b5b86 by Anon Ray at 2013-10-03 28
# Send the CORS header for images when browsers request it.
29
# https://developer.mozilla.org/en/CORS_Enabled_Image
30
# http://blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html
31
# http://hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/
3ce3fe9 by Anon Ray at 2012-11-23 32
33
<IfModule mod_setenvif.c>
29b5b86 by Anon Ray at 2013-10-03 34
    <IfModule mod_headers.c>
35
        <FilesMatch "\.(gif|ico|jpe?g|png|svgz?|webp)$">
36
            SetEnvIf Origin ":" IS_CORS
37
            Header set Access-Control-Allow-Origin "*" env=IS_CORS
38
        </FilesMatch>
39
    </IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 40
</IfModule>
41
29b5b86 by Anon Ray at 2013-10-03 42
# ------------------------------------------------------------------------------
43
# | Web fonts access                                                           |
44
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 45
29b5b86 by Anon Ray at 2013-10-03 46
# Allow access from all domains for web fonts
3ce3fe9 by Anon Ray at 2012-11-23 47
48
<IfModule mod_headers.c>
29b5b86 by Anon Ray at 2013-10-03 49
    <FilesMatch "\.(eot|font.css|otf|ttc|ttf|woff)$">
50
        Header set Access-Control-Allow-Origin "*"
51
    </FilesMatch>
3ce3fe9 by Anon Ray at 2012-11-23 52
</IfModule>
53
54
29b5b86 by Anon Ray at 2013-10-03 55
# ##############################################################################
56
# # ERRORS                                                                     #
57
# ##############################################################################
3ce3fe9 by Anon Ray at 2012-11-23 58
29b5b86 by Anon Ray at 2013-10-03 59
# ------------------------------------------------------------------------------
60
# | 404 error prevention for non-existing redirected folders                   |
61
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 62
29b5b86 by Anon Ray at 2013-10-03 63
# Prevent Apache from returning a 404 error for a rewrite if a directory
64
# with the same name does not exist.
65
# http://httpd.apache.org/docs/current/content-negotiation.html#multiviews
66
# http://www.webmasterworld.com/apache/3808792.htm
3ce3fe9 by Anon Ray at 2012-11-23 67
29b5b86 by Anon Ray at 2013-10-03 68
Options -MultiViews
3ce3fe9 by Anon Ray at 2012-11-23 69
29b5b86 by Anon Ray at 2013-10-03 70
# ------------------------------------------------------------------------------
71
# | Custom error messages / pages                                              |
72
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 73
29b5b86 by Anon Ray at 2013-10-03 74
# You can customize what Apache returns to the client in case of an error (see
75
# http://httpd.apache.org/docs/current/mod/core.html#errordocument), e.g.:
3ce3fe9 by Anon Ray at 2012-11-23 76
29b5b86 by Anon Ray at 2013-10-03 77
ErrorDocument 404 /404.html
3ce3fe9 by Anon Ray at 2012-11-23 78
79
29b5b86 by Anon Ray at 2013-10-03 80
# ##############################################################################
81
# # INTERNET EXPLORER                                                          #
82
# ##############################################################################
3ce3fe9 by Anon Ray at 2012-11-23 83
29b5b86 by Anon Ray at 2013-10-03 84
# ------------------------------------------------------------------------------
85
# | Better website experience                                                  |
86
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 87
29b5b86 by Anon Ray at 2013-10-03 88
# Force IE to render pages in the highest available mode in the various
89
# cases when it may not: http://hsivonen.iki.fi/doctype/ie-mode.pdf.
3ce3fe9 by Anon Ray at 2012-11-23 90
29b5b86 by Anon Ray at 2013-10-03 91
<IfModule mod_headers.c>
92
    Header set X-UA-Compatible "IE=edge"
93
    # `mod_headers` can't match based on the content-type, however, we only
94
    # want to send this header for HTML pages and not for the other resources
95
    <FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svgz?|ttf|vcf|webapp|webm|webp|woff|xml|xpi)$">
96
        Header unset X-UA-Compatible
97
    </FilesMatch>
98
</IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 99
29b5b86 by Anon Ray at 2013-10-03 100
# ------------------------------------------------------------------------------
101
# | Cookie setting from iframes                                                |
102
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 103
29b5b86 by Anon Ray at 2013-10-03 104
# Allow cookies to be set from iframes in IE.
3ce3fe9 by Anon Ray at 2012-11-23 105
29b5b86 by Anon Ray at 2013-10-03 106
# <IfModule mod_headers.c>
107
#   Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""
108
# </IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 109
29b5b86 by Anon Ray at 2013-10-03 110
# ------------------------------------------------------------------------------
111
# | Screen flicker                                                             |
112
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 113
29b5b86 by Anon Ray at 2013-10-03 114
# Stop screen flicker in IE on CSS rollovers (this only works in
115
# combination with the `ExpiresByType` directives for images from below).
3ce3fe9 by Anon Ray at 2012-11-23 116
29b5b86 by Anon Ray at 2013-10-03 117
# BrowserMatch "MSIE" brokenvary=1
118
# BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
119
# BrowserMatch "Opera" !brokenvary
120
# SetEnvIf brokenvary 1 force-no-vary
3ce3fe9 by Anon Ray at 2012-11-23 121
122
29b5b86 by Anon Ray at 2013-10-03 123
# ##############################################################################
124
# # MIME TYPES AND ENCODING                                                    #
125
# ##############################################################################
126
127
# ------------------------------------------------------------------------------
128
# | Proper MIME types for all files                                            |
129
# ------------------------------------------------------------------------------
130
131
<IfModule mod_mime.c>
132
133
  # Audio
134
    AddType audio/mp4                                   m4a f4a f4b
135
    AddType audio/ogg                                   oga ogg
136
137
  # JavaScript
138
    # Normalize to standard type (it's sniffed in IE anyways):
139
    # http://tools.ietf.org/html/rfc4329#section-7.2
140
    AddType application/javascript                      js
141
    AddType application/json                            json
142
143
  # Video
144
    AddType video/mp4                                   mp4 m4v f4v f4p
145
    AddType video/ogg                                   ogv
146
    AddType video/webm                                  webm
147
    AddType video/x-flv                                 flv
148
149
  # Web fonts
150
    AddType application/font-woff                       woff
151
    AddType application/vnd.ms-fontobject               eot
152
153
    # Browsers usually ignore the font MIME types and sniff the content,
154
    # however, Chrome shows a warning if other MIME types are used for the
155
    # following fonts.
156
    AddType application/x-font-ttf                      ttc ttf
157
    AddType font/opentype                               otf
158
159
    # Make SVGZ fonts work on iPad:
160
    # https://twitter.com/FontSquirrel/status/14855840545
161
    AddType     image/svg+xml                           svg svgz
162
    AddEncoding gzip                                    svgz
163
164
  # Other
165
    AddType application/octet-stream                    safariextz
166
    AddType application/x-chrome-extension              crx
167
    AddType application/x-opera-extension               oex
168
    AddType application/x-shockwave-flash               swf
169
    AddType application/x-web-app-manifest+json         webapp
170
    AddType application/x-xpinstall                     xpi
171
    AddType application/xml                             atom rdf rss xml
172
    AddType image/webp                                  webp
173
    AddType image/x-icon                                ico
174
    AddType text/cache-manifest                         appcache manifest
175
    AddType text/vtt                                    vtt
176
    AddType text/x-component                            htc
177
    AddType text/x-vcard                                vcf
3ce3fe9 by Anon Ray at 2012-11-23 178
29b5b86 by Anon Ray at 2013-10-03 179
</IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 180
29b5b86 by Anon Ray at 2013-10-03 181
# ------------------------------------------------------------------------------
182
# | UTF-8 encoding                                                             |
183
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 184
29b5b86 by Anon Ray at 2013-10-03 185
# Use UTF-8 encoding for anything served as `text/html` or `text/plain`.
186
AddDefaultCharset utf-8
3ce3fe9 by Anon Ray at 2012-11-23 187
29b5b86 by Anon Ray at 2013-10-03 188
# Force UTF-8 for certain file formats.
189
<IfModule mod_mime.c>
190
    AddCharset utf-8 .atom .css .js .json .rss .vtt .webapp .xml
3ce3fe9 by Anon Ray at 2012-11-23 191
</IfModule>
192
193
29b5b86 by Anon Ray at 2013-10-03 194
# ##############################################################################
195
# # URL REWRITES                                                               #
196
# ##############################################################################
3ce3fe9 by Anon Ray at 2012-11-23 197
29b5b86 by Anon Ray at 2013-10-03 198
# ------------------------------------------------------------------------------
199
# | Rewrite engine                                                             |
200
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 201
29b5b86 by Anon Ray at 2013-10-03 202
# Turning on the rewrite engine and enabling the `FollowSymLinks` option is
203
# necessary for the following directives to work.
3ce3fe9 by Anon Ray at 2012-11-23 204
29b5b86 by Anon Ray at 2013-10-03 205
# If your web host doesn't allow the `FollowSymlinks` option, you may need to
206
# comment it out and use `Options +SymLinksIfOwnerMatch` but, be aware of the
207
# performance impact: http://httpd.apache.org/docs/current/misc/perf-tuning.html#symlinks
3ce3fe9 by Anon Ray at 2012-11-23 208
29b5b86 by Anon Ray at 2013-10-03 209
# Also, some cloud hosting services require `RewriteBase` to be set:
210
# http://www.rackspace.com/knowledge_center/frequently-asked-question/why-is-mod-rewrite-not-working-on-my-site
3ce3fe9 by Anon Ray at 2012-11-23 211
29b5b86 by Anon Ray at 2013-10-03 212
<IfModule mod_rewrite.c>
213
    Options +FollowSymlinks
214
  # Options +SymLinksIfOwnerMatch
215
    RewriteEngine On
216
  # RewriteBase /
3ce3fe9 by Anon Ray at 2012-11-23 217
</IfModule>
218
29b5b86 by Anon Ray at 2013-10-03 219
# ------------------------------------------------------------------------------
220
# | Suppressing / Forcing the "www." at the beginning of URLs                  |
221
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 222
29b5b86 by Anon Ray at 2013-10-03 223
# The same content should never be available under two different URLs especially
224
# not with and without "www." at the beginning. This can cause SEO problems
225
# (duplicate content), therefore, you should choose one of the alternatives and
226
# redirect the other one.
3ce3fe9 by Anon Ray at 2012-11-23 227
29b5b86 by Anon Ray at 2013-10-03 228
# By default option 1 (no "www.") is activated:
229
# http://no-www.org/faq.php?q=class_b
3ce3fe9 by Anon Ray at 2012-11-23 230
29b5b86 by Anon Ray at 2013-10-03 231
# If you'd prefer to use option 2, just comment out all the lines from option 1
232
# and uncomment the ones from option 2.
3ce3fe9 by Anon Ray at 2012-11-23 233
29b5b86 by Anon Ray at 2013-10-03 234
# IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME!
3ce3fe9 by Anon Ray at 2012-11-23 235
29b5b86 by Anon Ray at 2013-10-03 236
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3ce3fe9 by Anon Ray at 2012-11-23 237
29b5b86 by Anon Ray at 2013-10-03 238
# Option 1: rewrite www.example.com → example.com
3ce3fe9 by Anon Ray at 2012-11-23 239
29b5b86 by Anon Ray at 2013-10-03 240
<IfModule mod_rewrite.c>
241
    RewriteCond %{HTTPS} !=on
242
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
243
    RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
244
</IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 245
29b5b86 by Anon Ray at 2013-10-03 246
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
247
248
# Option 2: rewrite example.com → www.example.com
249
250
# Be aware that the following might not be a good idea if you use "real"
251
# subdomains for certain parts of your website.
252
253
# <IfModule mod_rewrite.c>
254
#    RewriteCond %{HTTPS} !=on
255
#    RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
256
#    RewriteCond %{HTTP_HOST} !=localhost [NC]
257
#    RewriteCond %{HTTP_HOST} !=127.0.0.1
258
#    RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
3ce3fe9 by Anon Ray at 2012-11-23 259
# </IfModule>
260
261
29b5b86 by Anon Ray at 2013-10-03 262
# ##############################################################################
263
# # SECURITY                                                                   #
264
# ##############################################################################
265
266
# ------------------------------------------------------------------------------
267
# | Content Security Policy (CSP)                                              |
268
# ------------------------------------------------------------------------------
269
270
# You can mitigate the risk of cross-site scripting and other content-injection
271
# attacks by setting a Content Security Policy which whitelists trusted sources
272
# of content for your site.
3ce3fe9 by Anon Ray at 2012-11-23 273
29b5b86 by Anon Ray at 2013-10-03 274
# The example header below allows ONLY scripts that are loaded from the current
275
# site's origin (no inline scripts, no CDN, etc). This almost certainly won't
276
# work as-is for your site!
277
278
# To get all the details you'll need to craft a reasonable policy for your site,
279
# read: http://html5rocks.com/en/tutorials/security/content-security-policy (or
280
# see the specification: http://w3.org/TR/CSP).
3ce3fe9 by Anon Ray at 2012-11-23 281
282
# <IfModule mod_headers.c>
29b5b86 by Anon Ray at 2013-10-03 283
#    Header set Content-Security-Policy "script-src 'self'; object-src 'self'"
284
#    <FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svgz?|ttf|vcf|webapp|webm|webp|woff|xml|xpi)$">
285
#        Header unset Content-Security-Policy
286
#    </FilesMatch>
3ce3fe9 by Anon Ray at 2012-11-23 287
# </IfModule>
288
29b5b86 by Anon Ray at 2013-10-03 289
# ------------------------------------------------------------------------------
290
# | File access                                                                |
291
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 292
29b5b86 by Anon Ray at 2013-10-03 293
# Block access to directories without a default document.
294
# Usually you should leave this uncommented because you shouldn't allow anyone
295
# to surf through every directory on your server (which may includes rather
296
# private places like the CMS's directories).
3ce3fe9 by Anon Ray at 2012-11-23 297
29b5b86 by Anon Ray at 2013-10-03 298
<IfModule mod_autoindex.c>
299
    Options -Indexes
300
</IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 301
29b5b86 by Anon Ray at 2013-10-03 302
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3ce3fe9 by Anon Ray at 2012-11-23 303
29b5b86 by Anon Ray at 2013-10-03 304
# Block access to hidden files and directories.
305
# This includes directories used by version control systems such as Git and SVN.
3ce3fe9 by Anon Ray at 2012-11-23 306
307
<IfModule mod_rewrite.c>
29b5b86 by Anon Ray at 2013-10-03 308
    RewriteCond %{SCRIPT_FILENAME} -d [OR]
309
    RewriteCond %{SCRIPT_FILENAME} -f
310
    RewriteRule "(^|/)\." - [F]
3ce3fe9 by Anon Ray at 2012-11-23 311
</IfModule>
312
29b5b86 by Anon Ray at 2013-10-03 313
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3ce3fe9 by Anon Ray at 2012-11-23 314
29b5b86 by Anon Ray at 2013-10-03 315
# Block access to backup and source files.
316
# These files may be left by some text editors and can pose a great security
317
# danger when anyone has access to them.
3ce3fe9 by Anon Ray at 2012-11-23 318
29b5b86 by Anon Ray at 2013-10-03 319
<FilesMatch "(^#.*#|\.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|sw[op])|~)$">
320
    Order allow,deny
321
    Deny from all
322
    Satisfy All
323
</FilesMatch>
3ce3fe9 by Anon Ray at 2012-11-23 324
29b5b86 by Anon Ray at 2013-10-03 325
# ------------------------------------------------------------------------------
326
# | Secure Sockets Layer (SSL)                                                 |
327
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 328
29b5b86 by Anon Ray at 2013-10-03 329
# Rewrite secure requests properly to prevent SSL certificate warnings, e.g.:
330
# prevent `https://www.example.com` when your certificate only allows
331
# `https://secure.example.com`.
3ce3fe9 by Anon Ray at 2012-11-23 332
29b5b86 by Anon Ray at 2013-10-03 333
# <IfModule mod_rewrite.c>
334
#    RewriteCond %{SERVER_PORT} !^443
335
#    RewriteRule ^ https://example-domain-please-change-me.com%{REQUEST_URI} [R=301,L]
336
# </IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 337
29b5b86 by Anon Ray at 2013-10-03 338
# ------------------------------------------------------------------------------
339
# | HTTP Strict Transport Security (HSTS)                                      |
340
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 341
29b5b86 by Anon Ray at 2013-10-03 342
# Force client-side SSL redirection.
3ce3fe9 by Anon Ray at 2012-11-23 343
29b5b86 by Anon Ray at 2013-10-03 344
# If a user types "example.com" in his browser, the above rule will redirect
345
# him to the secure version of the site. That still leaves a window of oppor-
346
# tunity (the initial HTTP connection) for an attacker to downgrade or redirect
347
# the request. The following header ensures that browser will ONLY connect to
348
# your server via HTTPS, regardless of what the users type in the address bar.
349
# http://tools.ietf.org/html/draft-ietf-websec-strict-transport-sec-14#section-6.1
350
# http://www.html5rocks.com/en/tutorials/security/transport-layer-security/
3ce3fe9 by Anon Ray at 2012-11-23 351
29b5b86 by Anon Ray at 2013-10-03 352
# (!) Remove the `includeSubDomains` optional directive if the subdomains are
353
# not using HTTPS.
3ce3fe9 by Anon Ray at 2012-11-23 354
29b5b86 by Anon Ray at 2013-10-03 355
# <IfModule mod_headers.c>
356
#    Header set Strict-Transport-Security "max-age=16070400; includeSubDomains"
3ce3fe9 by Anon Ray at 2012-11-23 357
# </IfModule>
358
29b5b86 by Anon Ray at 2013-10-03 359
# ------------------------------------------------------------------------------
360
# | Server software information                                                |
361
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 362
29b5b86 by Anon Ray at 2013-10-03 363
# Avoid displaying the exact Apache version number, the description of the
364
# generic OS-type and the information about Apache's compiled-in modules.
3ce3fe9 by Anon Ray at 2012-11-23 365
29b5b86 by Anon Ray at 2013-10-03 366
# ADD THIS DIRECTIVE IN THE `httpd.conf` AS IT WILL NOT WORK IN THE `.htaccess`!
3ce3fe9 by Anon Ray at 2012-11-23 367
29b5b86 by Anon Ray at 2013-10-03 368
# ServerTokens Prod
3ce3fe9 by Anon Ray at 2012-11-23 369
370
29b5b86 by Anon Ray at 2013-10-03 371
# ##############################################################################
372
# # WEB PERFORMANCE                                                            #
373
# ##############################################################################
3ce3fe9 by Anon Ray at 2012-11-23 374
29b5b86 by Anon Ray at 2013-10-03 375
# ------------------------------------------------------------------------------
376
# | Compression                                                                |
377
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 378
29b5b86 by Anon Ray at 2013-10-03 379
<IfModule mod_deflate.c>
3ce3fe9 by Anon Ray at 2012-11-23 380
29b5b86 by Anon Ray at 2013-10-03 381
    # Force compression for mangled headers.
382
    # http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping
383
    <IfModule mod_setenvif.c>
384
        <IfModule mod_headers.c>
385
            SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
386
            RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
387
        </IfModule>
388
    </IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 389
29b5b86 by Anon Ray at 2013-10-03 390
    # Compress all output labeled with one of the following MIME-types
391
    # (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
392
    #  and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
393
    #  as `AddOutputFilterByType` is still in the core directives).
394
    <IfModule mod_filter.c>
395
        AddOutputFilterByType DEFLATE application/atom+xml \
396
                                      application/javascript \
397
                                      application/json \
398
                                      application/rss+xml \
399
                                      application/vnd.ms-fontobject \
400
                                      application/x-font-ttf \
401
                                      application/x-web-app-manifest+json \
402
                                      application/xhtml+xml \
403
                                      application/xml \
404
                                      font/opentype \
405
                                      image/svg+xml \
406
                                      image/x-icon \
407
                                      text/css \
408
                                      text/html \
409
                                      text/plain \
410
                                      text/x-component \
411
                                      text/xml
412
    </IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 413
29b5b86 by Anon Ray at 2013-10-03 414
</IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 415
29b5b86 by Anon Ray at 2013-10-03 416
# ------------------------------------------------------------------------------
417
# | Content transformations                                                    |
418
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 419
29b5b86 by Anon Ray at 2013-10-03 420
# Prevent some of the mobile network providers from modifying the content of
421
# your site: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.5.
3ce3fe9 by Anon Ray at 2012-11-23 422
29b5b86 by Anon Ray at 2013-10-03 423
# <IfModule mod_headers.c>
424
#    Header set Cache-Control "no-transform"
425
# </IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 426
29b5b86 by Anon Ray at 2013-10-03 427
# ------------------------------------------------------------------------------
428
# | ETag removal                                                               |
429
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 430
29b5b86 by Anon Ray at 2013-10-03 431
# Since we're sending far-future expires headers (see below), ETags can
432
# be removed: http://developer.yahoo.com/performance/rules.html#etags.
3ce3fe9 by Anon Ray at 2012-11-23 433
29b5b86 by Anon Ray at 2013-10-03 434
# `FileETag None` is not enough for every server.
435
<IfModule mod_headers.c>
436
    Header unset ETag
437
</IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 438
29b5b86 by Anon Ray at 2013-10-03 439
FileETag None
3ce3fe9 by Anon Ray at 2012-11-23 440
29b5b86 by Anon Ray at 2013-10-03 441
# ------------------------------------------------------------------------------
442
# | Expires headers (for better cache control)                                 |
443
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 444
29b5b86 by Anon Ray at 2013-10-03 445
# The following expires headers are set pretty far in the future. If you don't
446
# control versioning with filename-based cache busting, consider lowering the
447
# cache time for resources like CSS and JS to something like 1 week.
3ce3fe9 by Anon Ray at 2012-11-23 448
29b5b86 by Anon Ray at 2013-10-03 449
<IfModule mod_expires.c>
3ce3fe9 by Anon Ray at 2012-11-23 450
29b5b86 by Anon Ray at 2013-10-03 451
    ExpiresActive on
452
    ExpiresDefault                                      "access plus 1 month"
3ce3fe9 by Anon Ray at 2012-11-23 453
29b5b86 by Anon Ray at 2013-10-03 454
  # CSS
455
    ExpiresByType text/css                              "access plus 1 year"
3ce3fe9 by Anon Ray at 2012-11-23 456
29b5b86 by Anon Ray at 2013-10-03 457
  # Data interchange
458
    ExpiresByType application/json                      "access plus 0 seconds"
459
    ExpiresByType application/xml                       "access plus 0 seconds"
460
    ExpiresByType text/xml                              "access plus 0 seconds"
3ce3fe9 by Anon Ray at 2012-11-23 461
29b5b86 by Anon Ray at 2013-10-03 462
  # Favicon (cannot be renamed!)
463
    ExpiresByType image/x-icon                          "access plus 1 week"
3ce3fe9 by Anon Ray at 2012-11-23 464
29b5b86 by Anon Ray at 2013-10-03 465
  # HTML components (HTCs)
466
    ExpiresByType text/x-component                      "access plus 1 month"
3ce3fe9 by Anon Ray at 2012-11-23 467
29b5b86 by Anon Ray at 2013-10-03 468
  # HTML
469
    ExpiresByType text/html                             "access plus 0 seconds"
3ce3fe9 by Anon Ray at 2012-11-23 470
29b5b86 by Anon Ray at 2013-10-03 471
  # JavaScript
472
    ExpiresByType application/javascript                "access plus 1 year"
3ce3fe9 by Anon Ray at 2012-11-23 473
29b5b86 by Anon Ray at 2013-10-03 474
  # Manifest files
475
    ExpiresByType application/x-web-app-manifest+json   "access plus 0 seconds"
476
    ExpiresByType text/cache-manifest                   "access plus 0 seconds"
3ce3fe9 by Anon Ray at 2012-11-23 477
29b5b86 by Anon Ray at 2013-10-03 478
  # Media
479
    ExpiresByType audio/ogg                             "access plus 1 month"
480
    ExpiresByType image/gif                             "access plus 1 month"
481
    ExpiresByType image/jpeg                            "access plus 1 month"
482
    ExpiresByType image/png                             "access plus 1 month"
483
    ExpiresByType video/mp4                             "access plus 1 month"
484
    ExpiresByType video/ogg                             "access plus 1 month"
485
    ExpiresByType video/webm                            "access plus 1 month"
3ce3fe9 by Anon Ray at 2012-11-23 486
29b5b86 by Anon Ray at 2013-10-03 487
  # Web feeds
488
    ExpiresByType application/atom+xml                  "access plus 1 hour"
489
    ExpiresByType application/rss+xml                   "access plus 1 hour"
3ce3fe9 by Anon Ray at 2012-11-23 490
29b5b86 by Anon Ray at 2013-10-03 491
  # Web fonts
492
    ExpiresByType application/font-woff                 "access plus 1 month"
493
    ExpiresByType application/vnd.ms-fontobject         "access plus 1 month"
494
    ExpiresByType application/x-font-ttf                "access plus 1 month"
495
    ExpiresByType font/opentype                         "access plus 1 month"
496
    ExpiresByType image/svg+xml                         "access plus 1 month"
3ce3fe9 by Anon Ray at 2012-11-23 497
29b5b86 by Anon Ray at 2013-10-03 498
</IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 499
29b5b86 by Anon Ray at 2013-10-03 500
# ------------------------------------------------------------------------------
501
# | Filename-based cache busting                                               |
502
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 503
29b5b86 by Anon Ray at 2013-10-03 504
# If you're not using a build process to manage your filename version revving,
505
# you might want to consider enabling the following directives to route all
506
# requests such as `/css/style.12345.css` to `/css/style.css`.
3ce3fe9 by Anon Ray at 2012-11-23 507
29b5b86 by Anon Ray at 2013-10-03 508
# To understand why this is important and a better idea than `*.css?v231`, read:
509
# http://stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring
3ce3fe9 by Anon Ray at 2012-11-23 510
29b5b86 by Anon Ray at 2013-10-03 511
# <IfModule mod_rewrite.c>
512
#    RewriteCond %{REQUEST_FILENAME} !-f
513
#    RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
514
# </IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 515
29b5b86 by Anon Ray at 2013-10-03 516
# ------------------------------------------------------------------------------
517
# | File concatenation                                                         |
518
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 519
29b5b86 by Anon Ray at 2013-10-03 520
# Allow concatenation from within specific CSS and JS files, e.g.:
521
# Inside of `script.combined.js` you could have
522
#   <!--#include file="libs/jquery.js" -->
523
#   <!--#include file="plugins/jquery.idletimer.js" -->
524
# and they would be included into this single file.
3ce3fe9 by Anon Ray at 2012-11-23 525
29b5b86 by Anon Ray at 2013-10-03 526
# <IfModule mod_include.c>
527
#    <FilesMatch "\.combined\.js$">
528
#        Options +Includes
529
#        AddOutputFilterByType INCLUDES application/javascript application/json
530
#        SetOutputFilter INCLUDES
531
#    </FilesMatch>
532
#    <FilesMatch "\.combined\.css$">
533
#        Options +Includes
534
#        AddOutputFilterByType INCLUDES text/css
535
#        SetOutputFilter INCLUDES
536
#    </FilesMatch>
537
# </IfModule>
3ce3fe9 by Anon Ray at 2012-11-23 538
29b5b86 by Anon Ray at 2013-10-03 539
# ------------------------------------------------------------------------------
540
# | Persistent connections                                                     |
541
# ------------------------------------------------------------------------------
3ce3fe9 by Anon Ray at 2012-11-23 542
29b5b86 by Anon Ray at 2013-10-03 543
# Allow multiple requests to be sent over the same TCP connection:
544
# http://httpd.apache.org/docs/current/en/mod/core.html#keepalive.
545
546
# Enable if you serve a lot of static content but, be aware of the
547
# possible disadvantages!
548
549
# <IfModule mod_headers.c>
550
#    Header set Connection Keep-Alive
551
# </IfModule>