2 # Apache Server Configs v2.14.0 | MIT License
3 # https://github.com/h5bp/server-configs-apache
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.
9 # https://httpd.apache.org/docs/current/howto/htaccess.html.
11 # ######################################################################
13 # ######################################################################
15 # ----------------------------------------------------------------------
16 # | Cross-origin requests |
17 # ----------------------------------------------------------------------
19 # Allow cross-origin requests.
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/
25 # <IfModule mod_headers.c>
26 # Header set Access-Control-Allow-Origin "*"
29 # ----------------------------------------------------------------------
30 # | Cross-origin images |
31 # ----------------------------------------------------------------------
33 # Send the CORS header for images when browsers request it.
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
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
47 # ----------------------------------------------------------------------
48 # | Cross-origin web fonts |
49 # ----------------------------------------------------------------------
51 # Allow cross-origin access to web fonts.
53 <IfModule mod_headers.c>
54 <FilesMatch "\.(eot|otf|tt[cf]|woff2?)$">
55 Header set Access-Control-Allow-Origin "*"
59 # ----------------------------------------------------------------------
60 # | Cross-origin resource timing |
61 # ----------------------------------------------------------------------
63 # Allow cross-origin access to the timing information for all resources.
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
70 # http://www.w3.org/TR/resource-timing/
71 # http://www.stevesouders.com/blog/2014/08/21/resource-timing-practical-tips/
73 # <IfModule mod_headers.c>
74 # Header set Timing-Allow-Origin: "*"
78 # ######################################################################
80 # ######################################################################
82 # ----------------------------------------------------------------------
83 # | Custom error messages/pages |
84 # ----------------------------------------------------------------------
86 # Customize what Apache returns to the client in case of an error.
87 # https://httpd.apache.org/docs/current/mod/core.html#errordocument
89 ErrorDocument 404 /404.html
91 # ----------------------------------------------------------------------
92 # | Error prevention |
93 # ----------------------------------------------------------------------
95 # Disable the pattern matching based on filenames.
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.
100 # https://httpd.apache.org/docs/current/content-negotiation.html#multiviews
105 # ######################################################################
106 # # INTERNET EXPLORER #
107 # ######################################################################
109 # ----------------------------------------------------------------------
111 # ----------------------------------------------------------------------
113 # Force Internet Explorer 8/9/10 to render pages in the highest mode
114 # available in the various cases when it may not.
116 # https://hsivonen.fi/doctype/#ie8
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.
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
126 <IfModule mod_headers.c>
128 Header set X-UA-Compatible "IE=edge"
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.
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
140 # ----------------------------------------------------------------------
141 # | Iframes cookies |
142 # ----------------------------------------------------------------------
144 # Allow cookies to be set from iframes in Internet Explorer.
146 # https://msdn.microsoft.com/en-us/library/ms537343.aspx
147 # http://www.w3.org/TR/2000/CR-P3P-20001215/
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\""
154 # ######################################################################
155 # # MEDIA TYPES AND CHARACTER ENCODINGS #
156 # ######################################################################
158 # ----------------------------------------------------------------------
160 # ----------------------------------------------------------------------
162 # Serve resources with the proper media types (f.k.a. MIME types).
164 # https://www.iana.org/assignments/media-types/media-types.xhtml
165 # https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype
167 <IfModule mod_mime.c>
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
181 # Normalize to standard type.
182 # https://tools.ietf.org/html/rfc4329#section-7.2
184 AddType application/javascript js
189 AddType application/manifest+json webmanifest
190 AddType application/x-web-app-manifest+json webapp
191 AddType text/cache-manifest appcache
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
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
210 AddType image/x-icon cur ico
215 AddType application/font-woff woff
216 AddType application/font-woff2 woff2
217 AddType application/vnd.ms-fontobject eot
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
223 # However, Blink and WebKit based browsers will show a warning
224 # in the console if the following font types are served with any
227 AddType application/x-font-ttf ttc ttf
228 AddType font/opentype otf
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
241 AddType text/x-component htc
245 # ----------------------------------------------------------------------
246 # | Character encodings |
247 # ----------------------------------------------------------------------
249 # Serve all resources labeled as `text/html` or `text/plain`
250 # with the media type `charset` parameter set to `UTF-8`.
252 # https://httpd.apache.org/docs/current/mod/core.html#adddefaultcharset
254 AddDefaultCharset utf-8
256 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
258 # Serve the following file types with the media type `charset`
259 # parameter set to `UTF-8`.
261 # https://httpd.apache.org/docs/current/mod/mod_mime.html#addcharset
263 <IfModule mod_mime.c>
264 AddCharset utf-8 .atom \
283 # ######################################################################
285 # ######################################################################
287 # ----------------------------------------------------------------------
289 # ----------------------------------------------------------------------
291 # (1) Turn on the rewrite engine (this is necessary in order for
292 # the `RewriteRule` directives to work).
294 # https://httpd.apache.org/docs/current/mod/mod_rewrite.html#RewriteEngine
296 # (2) Enable the `FollowSymLinks` option if it isn't already.
298 # https://httpd.apache.org/docs/current/mod/core.html#options
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.
305 # https://httpd.apache.org/docs/current/misc/perf-tuning.html#symlinks
307 # (4) Some cloud hosting services will require you set `RewriteBase`.
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
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.
316 # https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteoptions
318 # (6) Set %{ENV:PROTO} variable, to allow rewrites to redirect with the
319 # appropriate schema automatically (http or https).
321 <IfModule mod_rewrite.c>
327 Options +FollowSymlinks
330 # Options +SymLinksIfOwnerMatch
336 # RewriteOptions <options>
339 RewriteCond %{HTTPS} =on
340 RewriteRule ^ - [env=proto:https]
341 RewriteCond %{HTTPS} !=on
342 RewriteRule ^ - [env=proto:http]
346 # ----------------------------------------------------------------------
347 # | Forcing `https://` |
348 # ----------------------------------------------------------------------
350 # Redirect from the `http://` to the `https://` version of the URL.
351 # https://wiki.apache.org/httpd/RewriteHTTPToHTTPS
353 # <IfModule mod_rewrite.c>
355 # RewriteCond %{HTTPS} !=on
356 # RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
359 # ----------------------------------------------------------------------
360 # | Suppressing / Forcing the `www.` at the beginning of URLs |
361 # ----------------------------------------------------------------------
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
369 # By default `Option 1` (no `www.`) is activated.
370 # http://no-www.org/faq.php?q=class_b
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`.
375 # (!) NEVER USE BOTH RULES AT THE SAME TIME!
377 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
379 # Option 1: rewrite www.example.com → example.com
381 <IfModule mod_rewrite.c>
383 RewriteCond %{HTTPS} !=on
384 RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
385 RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L]
388 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
390 # Option 2: rewrite example.com → www.example.com
392 # Be aware that the following might not be a good idea if you use "real"
393 # subdomains for certain parts of your website.
395 # <IfModule mod_rewrite.c>
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]
405 # ######################################################################
407 # ######################################################################
409 # ----------------------------------------------------------------------
411 # ----------------------------------------------------------------------
413 # Protect website against clickjacking.
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.
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.
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).
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.).
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.
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
443 # <IfModule mod_headers.c>
445 # Header set X-Frame-Options "DENY"
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.
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
457 # ----------------------------------------------------------------------
458 # | Content Security Policy (CSP) |
459 # ----------------------------------------------------------------------
461 # Mitigate the risk of cross-site scripting and other content-injection
464 # This can be done by setting a `Content Security Policy` which
465 # whitelists trusted sources of content for your website.
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!
471 # To make things easier, you can use an online CSP header generator
472 # such as: http://cspisawesome.com/.
474 # http://content-security-policy.com/
475 # http://www.html5rocks.com/en/tutorials/security/content-security-policy/
476 # http://www.w3.org/TR/CSP11/).
478 # <IfModule mod_headers.c>
480 # Header set Content-Security-Policy "script-src 'self'; object-src 'self'"
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.
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
492 # ----------------------------------------------------------------------
494 # ----------------------------------------------------------------------
496 # Block access to directories without a default document.
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).
502 <IfModule mod_autoindex.c>
506 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
508 # Block access to all hidden files and directories with the exception of
509 # the visible content from within the `/.well-known/` hidden directory.
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.
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.
520 # https://www.mnot.net/blog/2010/04/07/well-known
521 # https://tools.ietf.org/html/rfc5785
523 <IfModule mod_rewrite.c>
525 RewriteCond %{REQUEST_URI} "!(^|/)\.well-known/([^./]+./?)+$" [NC]
526 RewriteCond %{SCRIPT_FILENAME} -d [OR]
527 RewriteCond %{SCRIPT_FILENAME} -f
528 RewriteRule "(^|/)\." - [F]
531 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
533 # Block access to files that can expose sensitive information.
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.
539 # http://feross.org/cmsploit/
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..
547 <FilesMatch "(^#.*#|\.(bak|conf|dist|fla|in[ci]|log|psd|sh|sql|sw[op])|~)$">
550 <IfModule !mod_authz_core.c>
557 <IfModule mod_authz_core.c>
563 # ----------------------------------------------------------------------
564 # | HTTP Strict Transport Security (HSTS) |
565 # ----------------------------------------------------------------------
567 # Force client-side SSL redirection.
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.
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
578 # (!) Remove the `includeSubDomains` optional directive if the website's
579 # subdomains are not using HTTPS.
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
585 # <IfModule mod_headers.c>
586 # Header always set Strict-Transport-Security "max-age=16070400; includeSubDomains"
589 # ----------------------------------------------------------------------
590 # | Reducing MIME type security risks |
591 # ----------------------------------------------------------------------
593 # Prevent some browsers from MIME-sniffing the response.
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.
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/
605 <IfModule mod_headers.c>
606 Header set X-Content-Type-Options "nosniff"
609 # ----------------------------------------------------------------------
610 # | Reflected Cross-Site Scripting (XSS) attacks |
611 # ----------------------------------------------------------------------
613 # (1) Try to re-enable the cross-site scripting (XSS) filter built
614 # into most web browsers.
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`.
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
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
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.
635 # https://hackademix.net/2009/11/21/ies-xss-filter-creates-xss-vulnerabilities
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.
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
645 # <IfModule mod_headers.c>
648 # Header set X-XSS-Protection "1; mode=block"
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.
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
660 # ----------------------------------------------------------------------
661 # | Server-side technology information |
662 # ----------------------------------------------------------------------
664 # Remove the `X-Powered-By` response header that:
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)
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
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`)
678 # https://php.net/manual/en/ini.core.php#ini.expose-php
680 <IfModule mod_headers.c>
681 Header unset X-Powered-By
684 # ----------------------------------------------------------------------
685 # | Server software information |
686 # ----------------------------------------------------------------------
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.)
692 # https://httpd.apache.org/docs/current/mod/core.html#serversignature
696 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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.
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!
705 # https://httpd.apache.org/docs/current/mod/core.html#servertokens
710 # ######################################################################
711 # # WEB PERFORMANCE #
712 # ######################################################################
714 # ----------------------------------------------------------------------
716 # ----------------------------------------------------------------------
718 <IfModule mod_deflate.c>
720 # Force compression for mangled `Accept-Encoding` request headers
721 # https://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html
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
730 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
732 # Compress all output labeled with one of the following media types.
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.
739 # https://httpd.apache.org/docs/current/mod/mod_filter.html#addoutputfilterbytype
741 <IfModule mod_filter.c>
742 AddOutputFilterByType DEFLATE "application/atom+xml" \
743 "application/javascript" \
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" \
761 "image/vnd.microsoft.icon" \
763 "text/cache-manifest" \
769 "text/vnd.rim.location.xloc" \
772 "text/x-cross-domain-policy" \
777 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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!).
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
790 # https://httpd.apache.org/docs/current/mod/mod_mime.html#addencoding
792 <IfModule mod_mime.c>
793 AddEncoding gzip svgz
798 # ----------------------------------------------------------------------
799 # | Content transformation |
800 # ----------------------------------------------------------------------
802 # Prevent intermediate caches or proxies (e.g.: such as the ones
803 # used by mobile network providers) from modifying the website's
806 # https://tools.ietf.org/html/rfc2616#section-14.9.5
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.
814 # https://developers.google.com/speed/pagespeed/module/configuration#notransform
816 # <IfModule mod_headers.c>
817 # Header merge Cache-Control "no-transform"
820 # ----------------------------------------------------------------------
822 # ----------------------------------------------------------------------
824 # Remove `ETags` as resources are sent with far-future expires headers.
826 # https://developer.yahoo.com/performance/rules.html#etags
827 # https://tools.ietf.org/html/rfc7232#section-2.3
829 # `FileETag None` doesn't work in all cases.
830 <IfModule mod_headers.c>
836 # ----------------------------------------------------------------------
837 # | Expires headers |
838 # ----------------------------------------------------------------------
840 # Serve resources with far-future expires headers.
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.
846 # https://httpd.apache.org/docs/current/mod/mod_expires.html
848 <IfModule mod_expires.c>
851 ExpiresDefault "access plus 1 month"
855 ExpiresByType text/css "access plus 1 year"
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"
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"
872 # Favicon (cannot be renamed!) and cursor images
874 ExpiresByType image/vnd.microsoft.icon "access plus 1 week"
875 ExpiresByType image/x-icon "access plus 1 week"
879 ExpiresByType text/html "access plus 0 seconds"
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"
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"
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"
912 # Embedded OpenType (EOT)
913 ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
914 ExpiresByType font/eot "access plus 1 month"
917 ExpiresByType font/opentype "access plus 1 month"
920 ExpiresByType application/x-font-ttf "access plus 1 month"
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"
927 # Web Open Font Format (WOFF) 2.0
928 ExpiresByType application/font-woff2 "access plus 1 month"
933 ExpiresByType text/x-cross-domain-policy "access plus 1 week"
937 # ----------------------------------------------------------------------
938 # | File concatenation |
939 # ----------------------------------------------------------------------
941 # Allow concatenation from within specific files.
945 # If you have the following lines in a file called, for
946 # example, `main.combined.js`:
948 # <!--#include file="js/jquery.js" -->
949 # <!--#include file="js/jquery.timer.js" -->
951 # Apache will replace those lines with the content of the
954 # <IfModule mod_include.c>
955 # <FilesMatch "\.combined\.js$">
957 # AddOutputFilterByType INCLUDES application/javascript \
958 # application/x-javascript \
960 # SetOutputFilter INCLUDES
962 # <FilesMatch "\.combined\.css$">
964 # AddOutputFilterByType INCLUDES text/css
965 # SetOutputFilter INCLUDES
969 # ----------------------------------------------------------------------
970 # | Filename-based cache busting |
971 # ----------------------------------------------------------------------
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`.
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/
981 # <IfModule mod_rewrite.c>
983 # RewriteCond %{REQUEST_FILENAME} !-f
984 # RewriteRule ^(.+)\.(\d+)\.(bmp|css|cur|gif|ico|jpe?g|js|png|svgz?|webp|webmanifest)$ $1.$3 [L]