storing boilerplate huge .htaccess example, most of which can go directly into apache...
[feisty_meow.git] / infobase / configuration / htaccess / boilerplate_htaccess_apache.txt
1
2 # Apache Server Configs v2.14.0 | MIT License
3 # https://github.com/h5bp/server-configs-apache
4
5 # (!) Using `.htaccess` files slows down Apache, therefore, if you have
6 # access to the main server configuration file (which is usually called
7 # `httpd.conf`), you should add this logic there.
8 #
9 # https://httpd.apache.org/docs/current/howto/htaccess.html.
10
11 # ######################################################################
12 # # CROSS-ORIGIN                                                       #
13 # ######################################################################
14
15 # ----------------------------------------------------------------------
16 # | Cross-origin requests                                              |
17 # ----------------------------------------------------------------------
18
19 # Allow cross-origin requests.
20 #
21 # https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
22 # http://enable-cors.org/
23 # http://www.w3.org/TR/cors/
24
25 # <IfModule mod_headers.c>
26 #     Header set Access-Control-Allow-Origin "*"
27 # </IfModule>
28
29 # ----------------------------------------------------------------------
30 # | Cross-origin images                                                |
31 # ----------------------------------------------------------------------
32
33 # Send the CORS header for images when browsers request it.
34 #
35 # https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image
36 # https://blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html
37
38 <IfModule mod_setenvif.c>
39     <IfModule mod_headers.c>
40         <FilesMatch "\.(bmp|cur|gif|ico|jpe?g|png|svgz?|webp)$">
41             SetEnvIf Origin ":" IS_CORS
42             Header set Access-Control-Allow-Origin "*" env=IS_CORS
43         </FilesMatch>
44     </IfModule>
45 </IfModule>
46
47 # ----------------------------------------------------------------------
48 # | Cross-origin web fonts                                             |
49 # ----------------------------------------------------------------------
50
51 # Allow cross-origin access to web fonts.
52
53 <IfModule mod_headers.c>
54     <FilesMatch "\.(eot|otf|tt[cf]|woff2?)$">
55         Header set Access-Control-Allow-Origin "*"
56     </FilesMatch>
57 </IfModule>
58
59 # ----------------------------------------------------------------------
60 # | Cross-origin resource timing                                       |
61 # ----------------------------------------------------------------------
62
63 # Allow cross-origin access to the timing information for all resources.
64 #
65 # If a resource isn't served with a `Timing-Allow-Origin` header that
66 # would allow its timing information to be shared with the document,
67 # some of the attributes of the `PerformanceResourceTiming` object will
68 # be set to zero.
69 #
70 # http://www.w3.org/TR/resource-timing/
71 # http://www.stevesouders.com/blog/2014/08/21/resource-timing-practical-tips/
72
73 # <IfModule mod_headers.c>
74 #     Header set Timing-Allow-Origin: "*"
75 # </IfModule>
76
77
78 # ######################################################################
79 # # ERRORS                                                             #
80 # ######################################################################
81
82 # ----------------------------------------------------------------------
83 # | Custom error messages/pages                                        |
84 # ----------------------------------------------------------------------
85
86 # Customize what Apache returns to the client in case of an error.
87 # https://httpd.apache.org/docs/current/mod/core.html#errordocument
88
89 ErrorDocument 404 /404.html
90
91 # ----------------------------------------------------------------------
92 # | Error prevention                                                   |
93 # ----------------------------------------------------------------------
94
95 # Disable the pattern matching based on filenames.
96 #
97 # This setting prevents Apache from returning a 404 error as the result
98 # of a rewrite when the directory with the same name does not exist.
99 #
100 # https://httpd.apache.org/docs/current/content-negotiation.html#multiviews
101
102 Options -MultiViews
103
104
105 # ######################################################################
106 # # INTERNET EXPLORER                                                  #
107 # ######################################################################
108
109 # ----------------------------------------------------------------------
110 # | Document modes                                                     |
111 # ----------------------------------------------------------------------
112
113 # Force Internet Explorer 8/9/10 to render pages in the highest mode
114 # available in the various cases when it may not.
115 #
116 # https://hsivonen.fi/doctype/#ie8
117 #
118 # (!) Starting with Internet Explorer 11, document modes are deprecated.
119 # If your business still relies on older web apps and services that were
120 # designed for older versions of Internet Explorer, you might want to
121 # consider enabling `Enterprise Mode` throughout your company.
122 #
123 # https://msdn.microsoft.com/en-us/library/ie/bg182625.aspx#docmode
124 # http://blogs.msdn.com/b/ie/archive/2014/04/02/stay-up-to-date-with-enterprise-mode-for-internet-explorer-11.aspx
125
126 <IfModule mod_headers.c>
127
128     Header set X-UA-Compatible "IE=edge"
129
130     # `mod_headers` cannot match based on the content-type, however,
131     # the `X-UA-Compatible` response header should be send only for
132     # HTML documents and not for the other resources.
133
134     <FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
135         Header unset X-UA-Compatible
136     </FilesMatch>
137
138 </IfModule>
139
140 # ----------------------------------------------------------------------
141 # | Iframes cookies                                                    |
142 # ----------------------------------------------------------------------
143
144 # Allow cookies to be set from iframes in Internet Explorer.
145 #
146 # https://msdn.microsoft.com/en-us/library/ms537343.aspx
147 # http://www.w3.org/TR/2000/CR-P3P-20001215/
148
149 # <IfModule mod_headers.c>
150 #     Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""
151 # </IfModule>
152
153
154 # ######################################################################
155 # # MEDIA TYPES AND CHARACTER ENCODINGS                                #
156 # ######################################################################
157
158 # ----------------------------------------------------------------------
159 # | Media types                                                        |
160 # ----------------------------------------------------------------------
161
162 # Serve resources with the proper media types (f.k.a. MIME types).
163 #
164 # https://www.iana.org/assignments/media-types/media-types.xhtml
165 # https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype
166
167 <IfModule mod_mime.c>
168
169   # Data interchange
170
171     AddType application/atom+xml                        atom
172     AddType application/json                            json map topojson
173     AddType application/ld+json                         jsonld
174     AddType application/rss+xml                         rss
175     AddType application/vnd.geo+json                    geojson
176     AddType application/xml                             rdf xml
177
178
179   # JavaScript
180
181     # Normalize to standard type.
182     # https://tools.ietf.org/html/rfc4329#section-7.2
183
184     AddType application/javascript                      js
185
186
187   # Manifest files
188
189     AddType application/manifest+json                   webmanifest
190     AddType application/x-web-app-manifest+json         webapp
191     AddType text/cache-manifest                         appcache
192
193
194   # Media files
195
196     AddType audio/mp4                                   f4a f4b m4a
197     AddType audio/ogg                                   oga ogg opus
198     AddType image/bmp                                   bmp
199     AddType image/svg+xml                               svg svgz
200     AddType image/webp                                  webp
201     AddType video/mp4                                   f4v f4p m4v mp4
202     AddType video/ogg                                   ogv
203     AddType video/webm                                  webm
204     AddType video/x-flv                                 flv
205
206     # Serving `.ico` image files with a different media type
207     # prevents Internet Explorer from displaying then as images:
208     # https://github.com/h5bp/html5-boilerplate/commit/37b5fec090d00f38de64b591bcddcb205aadf8ee
209
210     AddType image/x-icon                                cur ico
211
212
213   # Web fonts
214
215     AddType application/font-woff                       woff
216     AddType application/font-woff2                      woff2
217     AddType application/vnd.ms-fontobject               eot
218
219     # Browsers usually ignore the font media types and simply sniff
220     # the bytes to figure out the font type.
221     # https://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern
222     #
223     # However, Blink and WebKit based browsers will show a warning
224     # in the console if the following font types are served with any
225     # other media types.
226
227     AddType application/x-font-ttf                      ttc ttf
228     AddType font/opentype                               otf
229
230
231   # Other
232
233     AddType application/octet-stream                    safariextz
234     AddType application/x-bb-appworld                   bbaw
235     AddType application/x-chrome-extension              crx
236     AddType application/x-opera-extension               oex
237     AddType application/x-xpinstall                     xpi
238     AddType text/vcard                                  vcard vcf
239     AddType text/vnd.rim.location.xloc                  xloc
240     AddType text/vtt                                    vtt
241     AddType text/x-component                            htc
242
243 </IfModule>
244
245 # ----------------------------------------------------------------------
246 # | Character encodings                                                |
247 # ----------------------------------------------------------------------
248
249 # Serve all resources labeled as `text/html` or `text/plain`
250 # with the media type `charset` parameter set to `UTF-8`.
251 #
252 # https://httpd.apache.org/docs/current/mod/core.html#adddefaultcharset
253
254 AddDefaultCharset utf-8
255
256 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
257
258 # Serve the following file types with the media type `charset`
259 # parameter set to `UTF-8`.
260 #
261 # https://httpd.apache.org/docs/current/mod/mod_mime.html#addcharset
262
263 <IfModule mod_mime.c>
264     AddCharset utf-8 .atom \
265                      .bbaw \
266                      .css \
267                      .geojson \
268                      .js \
269                      .json \
270                      .jsonld \
271                      .manifest \
272                      .rdf \
273                      .rss \
274                      .topojson \
275                      .vtt \
276                      .webapp \
277                      .webmanifest \
278                      .xloc \
279                      .xml
280 </IfModule>
281
282
283 # ######################################################################
284 # # REWRITES                                                           #
285 # ######################################################################
286
287 # ----------------------------------------------------------------------
288 # | Rewrite engine                                                     |
289 # ----------------------------------------------------------------------
290
291 # (1) Turn on the rewrite engine (this is necessary in order for
292 #     the `RewriteRule` directives to work).
293 #
294 #     https://httpd.apache.org/docs/current/mod/mod_rewrite.html#RewriteEngine
295 #
296 # (2) Enable the `FollowSymLinks` option if it isn't already.
297 #
298 #     https://httpd.apache.org/docs/current/mod/core.html#options
299 #
300 # (3) If your web host doesn't allow the `FollowSymlinks` option,
301 #     you need to comment it out or remove it, and then uncomment
302 #     the `Options +SymLinksIfOwnerMatch` line (4), but be aware
303 #     of the performance impact.
304 #
305 #     https://httpd.apache.org/docs/current/misc/perf-tuning.html#symlinks
306 #
307 # (4) Some cloud hosting services will require you set `RewriteBase`.
308 #
309 #     https://www.rackspace.com/knowledge_center/frequently-asked-question/why-is-modrewrite-not-working-on-my-site
310 #     https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
311 #
312 # (5) Depending on how your server is set up, you may also need to
313 #     use the `RewriteOptions` directive to enable some options for
314 #     the rewrite engine.
315 #
316 #     https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteoptions
317 #
318 # (6) Set %{ENV:PROTO} variable, to allow rewrites to redirect with the
319 #     appropriate schema automatically (http or https).
320
321 <IfModule mod_rewrite.c>
322
323     # (1)
324     RewriteEngine On
325
326     # (2)
327     Options +FollowSymlinks
328
329     # (3)
330     # Options +SymLinksIfOwnerMatch
331
332     # (4)
333     # RewriteBase /
334
335     # (5)
336     # RewriteOptions <options>
337
338     # (6)
339     RewriteCond %{HTTPS} =on
340     RewriteRule ^ - [env=proto:https]
341     RewriteCond %{HTTPS} !=on
342     RewriteRule ^ - [env=proto:http]
343
344 </IfModule>
345
346 # ----------------------------------------------------------------------
347 # | Forcing `https://`                                                 |
348 # ----------------------------------------------------------------------
349
350 # Redirect from the `http://` to the `https://` version of the URL.
351 # https://wiki.apache.org/httpd/RewriteHTTPToHTTPS
352
353 # <IfModule mod_rewrite.c>
354 #    RewriteEngine On
355 #    RewriteCond %{HTTPS} !=on
356 #    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
357 # </IfModule>
358
359 # ----------------------------------------------------------------------
360 # | Suppressing / Forcing the `www.` at the beginning of URLs          |
361 # ----------------------------------------------------------------------
362
363 # The same content should never be available under two different
364 # URLs, especially not with and without `www.` at the beginning.
365 # This can cause SEO problems (duplicate content), and therefore,
366 # you should choose one of the alternatives and redirect the other
367 # one.
368 #
369 # By default `Option 1` (no `www.`) is activated.
370 # http://no-www.org/faq.php?q=class_b
371 #
372 # If you would prefer to use `Option 2`, just comment out all the
373 # lines from `Option 1` and uncomment the ones from `Option 2`.
374 #
375 # (!) NEVER USE BOTH RULES AT THE SAME TIME!
376
377 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
378
379 # Option 1: rewrite www.example.com â†’ example.com
380
381 <IfModule mod_rewrite.c>
382     RewriteEngine On
383     RewriteCond %{HTTPS} !=on
384     RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
385     RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L]
386 </IfModule>
387
388 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
389
390 # Option 2: rewrite example.com â†’ www.example.com
391 #
392 # Be aware that the following might not be a good idea if you use "real"
393 # subdomains for certain parts of your website.
394
395 # <IfModule mod_rewrite.c>
396 #     RewriteEngine On
397 #     RewriteCond %{HTTPS} !=on
398 #     RewriteCond %{HTTP_HOST} !^www\. [NC]
399 #     RewriteCond %{SERVER_ADDR} !=127.0.0.1
400 #     RewriteCond %{SERVER_ADDR} !=::1
401 #     RewriteRule ^ %{ENV:PROTO}://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
402 # </IfModule>
403
404
405 # ######################################################################
406 # # SECURITY                                                           #
407 # ######################################################################
408
409 # ----------------------------------------------------------------------
410 # | Clickjacking                                                       |
411 # ----------------------------------------------------------------------
412
413 # Protect website against clickjacking.
414 #
415 # The example below sends the `X-Frame-Options` response header with
416 # the value `DENY`, informing browsers not to display the content of
417 # the web page in any frame.
418 #
419 # This might not be the best setting for everyone. You should read
420 # about the other two possible values the `X-Frame-Options` header
421 # field can have: `SAMEORIGIN` and `ALLOW-FROM`.
422 # https://tools.ietf.org/html/rfc7034#section-2.1.
423 #
424 # Keep in mind that while you could send the `X-Frame-Options` header
425 # for all of your website’s pages, this has the potential downside that
426 # it forbids even non-malicious framing of your content (e.g.: when
427 # users visit your website using a Google Image Search results page).
428 #
429 # Nonetheless, you should ensure that you send the `X-Frame-Options`
430 # header for all pages that allow a user to make a state changing
431 # operation (e.g: pages that contain one-click purchase links, checkout
432 # or bank-transfer confirmation pages, pages that make permanent
433 # configuration changes, etc.).
434 #
435 # Sending the `X-Frame-Options` header can also protect your website
436 # against more than just clickjacking attacks:
437 # https://cure53.de/xfo-clickjacking.pdf.
438 #
439 # https://tools.ietf.org/html/rfc7034
440 # http://blogs.msdn.com/b/ieinternals/archive/2010/03/30/combating-clickjacking-with-x-frame-options.aspx
441 # https://www.owasp.org/index.php/Clickjacking
442
443 # <IfModule mod_headers.c>
444
445 #     Header set X-Frame-Options "DENY"
446
447 #     # `mod_headers` cannot match based on the content-type, however,
448 #     # the `X-Frame-Options` response header should be send only for
449 #     # HTML documents and not for the other resources.
450
451 #     <FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
452 #         Header unset X-Frame-Options
453 #     </FilesMatch>
454
455 # </IfModule>
456
457 # ----------------------------------------------------------------------
458 # | Content Security Policy (CSP)                                      |
459 # ----------------------------------------------------------------------
460
461 # Mitigate the risk of cross-site scripting and other content-injection
462 # attacks.
463 #
464 # This can be done by setting a `Content Security Policy` which
465 # whitelists trusted sources of content for your website.
466 #
467 # The example header below allows ONLY scripts that are loaded from
468 # the current website's origin (no inline scripts, no CDN, etc).
469 # That almost certainly won't work as-is for your website!
470 #
471 # To make things easier, you can use an online CSP header generator
472 # such as: http://cspisawesome.com/.
473 #
474 # http://content-security-policy.com/
475 # http://www.html5rocks.com/en/tutorials/security/content-security-policy/
476 # http://www.w3.org/TR/CSP11/).
477
478 # <IfModule mod_headers.c>
479
480 #     Header set Content-Security-Policy "script-src 'self'; object-src 'self'"
481
482 #     # `mod_headers` cannot match based on the content-type, however,
483 #     # the `Content-Security-Policy` response header should be send
484 #     # only for HTML documents and not for the other resources.
485
486 #     <FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
487 #         Header unset Content-Security-Policy
488 #     </FilesMatch>
489
490 # </IfModule>
491
492 # ----------------------------------------------------------------------
493 # | File access                                                        |
494 # ----------------------------------------------------------------------
495
496 # Block access to directories without a default document.
497 #
498 # You should leave the following uncommented, as you shouldn't allow
499 # anyone to surf through every directory on your server (which may
500 # includes rather private places such as the CMS's directories).
501
502 <IfModule mod_autoindex.c>
503     Options -Indexes
504 </IfModule>
505
506 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
507
508 # Block access to all hidden files and directories with the exception of
509 # the visible content from within the `/.well-known/` hidden directory.
510 #
511 # These types of files usually contain user preferences or the preserved
512 # state of an utility, and can include rather private places like, for
513 # example, the `.git` or `.svn` directories.
514 #
515 # The `/.well-known/` directory represents the standard (RFC 5785) path
516 # prefix for "well-known locations" (e.g.: `/.well-known/manifest.json`,
517 # `/.well-known/keybase.txt`), and therefore, access to its visible
518 # content should not be blocked.
519 #
520 # https://www.mnot.net/blog/2010/04/07/well-known
521 # https://tools.ietf.org/html/rfc5785
522
523 <IfModule mod_rewrite.c>
524     RewriteEngine On
525     RewriteCond %{REQUEST_URI} "!(^|/)\.well-known/([^./]+./?)+$" [NC]
526     RewriteCond %{SCRIPT_FILENAME} -d [OR]
527     RewriteCond %{SCRIPT_FILENAME} -f
528     RewriteRule "(^|/)\." - [F]
529 </IfModule>
530
531 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
532
533 # Block access to files that can expose sensitive information.
534 #
535 # By default, block access to backup and source files that may be
536 # left by some text editors and can pose a security risk when anyone
537 # has access to them.
538 #
539 # http://feross.org/cmsploit/
540 #
541 # (!) Update the `<FilesMatch>` regular expression from below to
542 # include any files that might end up on your production server and
543 # can expose sensitive information about your website. These files may
544 # include: configuration files, files that contain metadata about the
545 # project (e.g.: project dependencies), build scripts, etc..
546
547 <FilesMatch "(^#.*#|\.(bak|conf|dist|fla|in[ci]|log|psd|sh|sql|sw[op])|~)$">
548
549     # Apache < 2.3
550     <IfModule !mod_authz_core.c>
551         Order allow,deny
552         Deny from all
553         Satisfy All
554     </IfModule>
555
556     # Apache â‰¥ 2.3
557     <IfModule mod_authz_core.c>
558         Require all denied
559     </IfModule>
560
561 </FilesMatch>
562
563 # ----------------------------------------------------------------------
564 # | HTTP Strict Transport Security (HSTS)                              |
565 # ----------------------------------------------------------------------
566
567 # Force client-side SSL redirection.
568 #
569 # If a user types `example.com` in their browser, even if the server
570 # redirects them to the secure version of the website, that still leaves
571 # a window of opportunity (the initial HTTP connection) for an attacker
572 # to downgrade or redirect the request.
573 #
574 # The following header ensures that browser will ONLY connect to your
575 # server via HTTPS, regardless of what the users type in the browser's
576 # address bar.
577 #
578 # (!) Remove the `includeSubDomains` optional directive if the website's
579 # subdomains are not using HTTPS.
580 #
581 # http://www.html5rocks.com/en/tutorials/security/transport-layer-security/
582 # https://tools.ietf.org/html/draft-ietf-websec-strict-transport-sec-14#section-6.1
583 # http://blogs.msdn.com/b/ieinternals/archive/2014/08/18/hsts-strict-transport-security-attacks-mitigations-deployment-https.aspx
584
585 # <IfModule mod_headers.c>
586 #     Header always set Strict-Transport-Security "max-age=16070400; includeSubDomains"
587 # </IfModule>
588
589 # ----------------------------------------------------------------------
590 # | Reducing MIME type security risks                                  |
591 # ----------------------------------------------------------------------
592
593 # Prevent some browsers from MIME-sniffing the response.
594 #
595 # This reduces exposure to drive-by download attacks and cross-origin
596 # data leaks, and should be left uncommented, especially if the server
597 # is serving user-uploaded content or content that could potentially be
598 # treated as executable by the browser.
599 #
600 # http://www.slideshare.net/hasegawayosuke/owasp-hasegawa
601 # http://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-protection.aspx
602 # https://msdn.microsoft.com/en-us/library/ie/gg622941.aspx
603 # https://mimesniff.spec.whatwg.org/
604
605 <IfModule mod_headers.c>
606     Header set X-Content-Type-Options "nosniff"
607 </IfModule>
608
609 # ----------------------------------------------------------------------
610 # | Reflected Cross-Site Scripting (XSS) attacks                       |
611 # ----------------------------------------------------------------------
612
613 # (1) Try to re-enable the cross-site scripting (XSS) filter built
614 #     into most web browsers.
615 #
616 #     The filter is usually enabled by default, but in some cases it
617 #     may be disabled by the user. However, in Internet Explorer for
618 #     example, it can be re-enabled just by sending the
619 #     `X-XSS-Protection` header with the value of `1`.
620 #
621 # (2) Prevent web browsers from rendering the web page if a potential
622 #     reflected (a.k.a non-persistent) XSS attack is detected by the
623 #     filter.
624 #
625 #     By default, if the filter is enabled and browsers detect a
626 #     reflected XSS attack, they will attempt to block the attack
627 #     by making the smallest possible modifications to the returned
628 #     web page.
629 #
630 #     Unfortunately, in some browsers (e.g.: Internet Explorer),
631 #     this default behavior may allow the XSS filter to be exploited,
632 #     thereby, it's better to inform browsers to prevent the rendering
633 #     of the page altogether, instead of attempting to modify it.
634 #
635 #     https://hackademix.net/2009/11/21/ies-xss-filter-creates-xss-vulnerabilities
636 #
637 # (!) Do not rely on the XSS filter to prevent XSS attacks! Ensure that
638 #     you are taking all possible measures to prevent XSS attacks, the
639 #     most obvious being: validating and sanitizing your website's inputs.
640 #
641 # http://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part-iv-the-xss-filter.aspx
642 # http://blogs.msdn.com/b/ieinternals/archive/2011/01/31/controlling-the-internet-explorer-xss-filter-with-the-x-xss-protection-http-header.aspx
643 # https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
644
645 # <IfModule mod_headers.c>
646
647 #     #                           (1)    (2)
648 #     Header set X-XSS-Protection "1; mode=block"
649
650 #     # `mod_headers` cannot match based on the content-type, however,
651 #     # the `X-XSS-Protection` response header should be send only for
652 #     # HTML documents and not for the other resources.
653
654 #     <FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
655 #         Header unset X-XSS-Protection
656 #     </FilesMatch>
657
658 # </IfModule>
659
660 # ----------------------------------------------------------------------
661 # | Server-side technology information                                 |
662 # ----------------------------------------------------------------------
663
664 # Remove the `X-Powered-By` response header that:
665 #
666 #  * is set by some frameworks and server-side languages
667 #    (e.g.: ASP.NET, PHP), and its value contains information
668 #    about them (e.g.: their name, version number)
669 #
670 #  * doesn't provide any value as far as users are concern,
671 #    and in some cases, the information provided by it can
672 #    be used by attackers
673 #
674 # (!) If you can, you should disable the `X-Powered-By` header from the
675 # language / framework level (e.g.: for PHP, you can do that by setting
676 # `expose_php = off` in `php.ini`)
677 #
678 # https://php.net/manual/en/ini.core.php#ini.expose-php
679
680 <IfModule mod_headers.c>
681     Header unset X-Powered-By
682 </IfModule>
683
684 # ----------------------------------------------------------------------
685 # | Server software information                                        |
686 # ----------------------------------------------------------------------
687
688 # Prevent Apache from adding a trailing footer line containing
689 # information about the server to the server-generated documents
690 # (e.g.: error messages, directory listings, etc.)
691 #
692 # https://httpd.apache.org/docs/current/mod/core.html#serversignature
693
694 ServerSignature Off
695
696 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
697
698 # Prevent Apache from sending in the `Server` response header its
699 # exact version number, the description of the generic OS-type or
700 # information about its compiled-in modules.
701 #
702 # (!) The `ServerTokens` directive will only work in the main server
703 # configuration file, so don't try to enable it in the `.htaccess` file!
704 #
705 # https://httpd.apache.org/docs/current/mod/core.html#servertokens
706
707 #ServerTokens Prod
708
709
710 # ######################################################################
711 # # WEB PERFORMANCE                                                    #
712 # ######################################################################
713
714 # ----------------------------------------------------------------------
715 # | Compression                                                        |
716 # ----------------------------------------------------------------------
717
718 <IfModule mod_deflate.c>
719
720     # Force compression for mangled `Accept-Encoding` request headers
721     # https://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html
722
723     <IfModule mod_setenvif.c>
724         <IfModule mod_headers.c>
725             SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
726             RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
727         </IfModule>
728     </IfModule>
729
730     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
731
732     # Compress all output labeled with one of the following media types.
733     #
734     # (!) For Apache versions below version 2.3.7 you don't need to
735     # enable `mod_filter` and can remove the `<IfModule mod_filter.c>`
736     # and `</IfModule>` lines as `AddOutputFilterByType` is still in
737     # the core directives.
738     #
739     # https://httpd.apache.org/docs/current/mod/mod_filter.html#addoutputfilterbytype
740
741     <IfModule mod_filter.c>
742         AddOutputFilterByType DEFLATE "application/atom+xml" \
743                                       "application/javascript" \
744                                       "application/json" \
745                                       "application/ld+json" \
746                                       "application/manifest+json" \
747                                       "application/rdf+xml" \
748                                       "application/rss+xml" \
749                                       "application/schema+json" \
750                                       "application/vnd.geo+json" \
751                                       "application/vnd.ms-fontobject" \
752                                       "application/x-font-ttf" \
753                                       "application/x-javascript" \
754                                       "application/x-web-app-manifest+json" \
755                                       "application/xhtml+xml" \
756                                       "application/xml" \
757                                       "font/eot" \
758                                       "font/opentype" \
759                                       "image/bmp" \
760                                       "image/svg+xml" \
761                                       "image/vnd.microsoft.icon" \
762                                       "image/x-icon" \
763                                       "text/cache-manifest" \
764                                       "text/css" \
765                                       "text/html" \
766                                       "text/javascript" \
767                                       "text/plain" \
768                                       "text/vcard" \
769                                       "text/vnd.rim.location.xloc" \
770                                       "text/vtt" \
771                                       "text/x-component" \
772                                       "text/x-cross-domain-policy" \
773                                       "text/xml"
774
775     </IfModule>
776
777     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
778
779     # Map the following filename extensions to the specified
780     # encoding type in order to make Apache serve the file types
781     # with the appropriate `Content-Encoding` response header
782     # (do note that this will NOT make Apache compress them!).
783     #
784     # If these files types would be served without an appropriate
785     # `Content-Enable` response header, client applications (e.g.:
786     # browsers) wouldn't know that they first need to uncompress
787     # the response, and thus, wouldn't be able to understand the
788     # content.
789     #
790     # https://httpd.apache.org/docs/current/mod/mod_mime.html#addencoding
791
792     <IfModule mod_mime.c>
793         AddEncoding gzip              svgz
794     </IfModule>
795
796 </IfModule>
797
798 # ----------------------------------------------------------------------
799 # | Content transformation                                             |
800 # ----------------------------------------------------------------------
801
802 # Prevent intermediate caches or proxies (e.g.: such as the ones
803 # used by mobile network providers) from modifying the website's
804 # content.
805 #
806 # https://tools.ietf.org/html/rfc2616#section-14.9.5
807 #
808 # (!) If you are using `mod_pagespeed`, please note that setting
809 # the `Cache-Control: no-transform` response header will prevent
810 # `PageSpeed` from rewriting `HTML` files, and, if the
811 # `ModPagespeedDisableRewriteOnNoTransform` directive isn't set
812 # to `off`, also from rewriting other resources.
813 #
814 # https://developers.google.com/speed/pagespeed/module/configuration#notransform
815
816 # <IfModule mod_headers.c>
817 #     Header merge Cache-Control "no-transform"
818 # </IfModule>
819
820 # ----------------------------------------------------------------------
821 # | ETags                                                              |
822 # ----------------------------------------------------------------------
823
824 # Remove `ETags` as resources are sent with far-future expires headers.
825 #
826 # https://developer.yahoo.com/performance/rules.html#etags
827 # https://tools.ietf.org/html/rfc7232#section-2.3
828
829 # `FileETag None` doesn't work in all cases.
830 <IfModule mod_headers.c>
831     Header unset ETag
832 </IfModule>
833
834 FileETag None
835
836 # ----------------------------------------------------------------------
837 # | Expires headers                                                    |
838 # ----------------------------------------------------------------------
839
840 # Serve resources with far-future expires headers.
841 #
842 # (!) If you don't control versioning with filename-based
843 # cache busting, you should consider lowering the cache times
844 # to something like one week.
845 #
846 # https://httpd.apache.org/docs/current/mod/mod_expires.html
847
848 <IfModule mod_expires.c>
849
850     ExpiresActive on
851     ExpiresDefault                                      "access plus 1 month"
852
853   # CSS
854
855     ExpiresByType text/css                              "access plus 1 year"
856
857
858   # Data interchange
859
860     ExpiresByType application/atom+xml                  "access plus 1 hour"
861     ExpiresByType application/rdf+xml                   "access plus 1 hour"
862     ExpiresByType application/rss+xml                   "access plus 1 hour"
863
864     ExpiresByType application/json                      "access plus 0 seconds"
865     ExpiresByType application/ld+json                   "access plus 0 seconds"
866     ExpiresByType application/schema+json               "access plus 0 seconds"
867     ExpiresByType application/vnd.geo+json              "access plus 0 seconds"
868     ExpiresByType application/xml                       "access plus 0 seconds"
869     ExpiresByType text/xml                              "access plus 0 seconds"
870
871
872   # Favicon (cannot be renamed!) and cursor images
873
874     ExpiresByType image/vnd.microsoft.icon              "access plus 1 week"
875     ExpiresByType image/x-icon                          "access plus 1 week"
876
877   # HTML
878
879     ExpiresByType text/html                             "access plus 0 seconds"
880
881
882   # JavaScript
883
884     ExpiresByType application/javascript                "access plus 1 year"
885     ExpiresByType application/x-javascript              "access plus 1 year"
886     ExpiresByType text/javascript                       "access plus 1 year"
887
888
889   # Manifest files
890
891     ExpiresByType application/manifest+json             "access plus 1 week"
892     ExpiresByType application/x-web-app-manifest+json   "access plus 0 seconds"
893     ExpiresByType text/cache-manifest                   "access plus 0 seconds"
894
895
896   # Media files
897
898     ExpiresByType audio/ogg                             "access plus 1 month"
899     ExpiresByType image/bmp                             "access plus 1 month"
900     ExpiresByType image/gif                             "access plus 1 month"
901     ExpiresByType image/jpeg                            "access plus 1 month"
902     ExpiresByType image/png                             "access plus 1 month"
903     ExpiresByType image/svg+xml                         "access plus 1 month"
904     ExpiresByType image/webp                            "access plus 1 month"
905     ExpiresByType video/mp4                             "access plus 1 month"
906     ExpiresByType video/ogg                             "access plus 1 month"
907     ExpiresByType video/webm                            "access plus 1 month"
908
909
910   # Web fonts
911
912     # Embedded OpenType (EOT)
913     ExpiresByType application/vnd.ms-fontobject         "access plus 1 month"
914     ExpiresByType font/eot                              "access plus 1 month"
915
916     # OpenType
917     ExpiresByType font/opentype                         "access plus 1 month"
918
919     # TrueType
920     ExpiresByType application/x-font-ttf                "access plus 1 month"
921
922     # Web Open Font Format (WOFF) 1.0
923     ExpiresByType application/font-woff                 "access plus 1 month"
924     ExpiresByType application/x-font-woff               "access plus 1 month"
925     ExpiresByType font/woff                             "access plus 1 month"
926
927     # Web Open Font Format (WOFF) 2.0
928     ExpiresByType application/font-woff2                "access plus 1 month"
929
930
931   # Other
932
933     ExpiresByType text/x-cross-domain-policy            "access plus 1 week"
934
935 </IfModule>
936
937 # ----------------------------------------------------------------------
938 # | File concatenation                                                 |
939 # ----------------------------------------------------------------------
940
941 # Allow concatenation from within specific files.
942 #
943 # e.g.:
944 #
945 #   If you have the following lines in a file called, for
946 #   example, `main.combined.js`:
947 #
948 #       <!--#include file="js/jquery.js" -->
949 #       <!--#include file="js/jquery.timer.js" -->
950 #
951 #   Apache will replace those lines with the content of the
952 #   specified files.
953
954 # <IfModule mod_include.c>
955 #     <FilesMatch "\.combined\.js$">
956 #         Options +Includes
957 #         AddOutputFilterByType INCLUDES application/javascript \
958 #                                        application/x-javascript \
959 #                                        text/javascript
960 #         SetOutputFilter INCLUDES
961 #     </FilesMatch>
962 #     <FilesMatch "\.combined\.css$">
963 #         Options +Includes
964 #         AddOutputFilterByType INCLUDES text/css
965 #         SetOutputFilter INCLUDES
966 #     </FilesMatch>
967 # </IfModule>
968
969 # ----------------------------------------------------------------------
970 # | Filename-based cache busting                                       |
971 # ----------------------------------------------------------------------
972
973 # If you're not using a build process to manage your filename version
974 # revving, you might want to consider enabling the following directives
975 # to route all requests such as `/style.12345.css` to `/style.css`.
976 #
977 # To understand why this is important and even a better solution than
978 # using something like `*.css?v231`, please see:
979 # http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
980
981 # <IfModule mod_rewrite.c>
982 #     RewriteEngine On
983 #     RewriteCond %{REQUEST_FILENAME} !-f
984 #     RewriteRule ^(.+)\.(\d+)\.(bmp|css|cur|gif|ico|jpe?g|js|png|svgz?|webp|webmanifest)$ $1.$3 [L]
985 # </IfModule>
986
987