1
- # Apache Server Configs v3.0 .0 | MIT License
1
+ # Apache Server Configs v3.1 .0 | MIT License
2
2
# https://github.com/h5bp/server-configs-apache
3
3
4
4
# (!) Using `.htaccess` files slows down Apache, therefore, if you have
48
48
# ----------------------------------------------------------------------
49
49
50
50
# Allow cross-origin access to web fonts.
51
+ #
52
+ # https://developers.google.com/fonts/docs/troubleshooting
51
53
52
54
<IfModule mod_headers.c >
53
55
<FilesMatch "\.(eot|otf|tt[cf]|woff2?)$" >
66
68
# some of the attributes of the `PerformanceResourceTiming` object will
67
69
# be set to zero.
68
70
#
71
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Timing-Allow-Origin
69
72
# https://www.w3.org/TR/resource-timing/
70
- # http ://www.stevesouders.com/blog/2014/08/21/resource-timing-practical-tips/
73
+ # https ://www.stevesouders.com/blog/2014/08/21/resource-timing-practical-tips/
71
74
72
75
# <IfModule mod_headers.c>
73
76
# Header set Timing-Allow-Origin: "*"
82
85
# ----------------------------------------------------------------------
83
86
84
87
# Customize what Apache returns to the client in case of an error.
88
+ #
85
89
# https://httpd.apache.org/docs/current/mod/core.html#errordocument
86
90
87
91
ErrorDocument 404 /404 .html
@@ -119,13 +123,14 @@ Options -MultiViews
119
123
#
120
124
# https://msdn.microsoft.com/en-us/library/ie/bg182625.aspx#docmode
121
125
# https://blogs.msdn.microsoft.com/ie/2014/04/02/stay-up-to-date-with-enterprise-mode-for-internet-explorer-11/
126
+ # https://msdn.microsoft.com/en-us/library/ff955275.aspx
122
127
123
128
<IfModule mod_headers.c >
124
129
125
130
Header set X-UA-Compatible "IE=edge"
126
131
127
132
# `mod_headers` cannot match based on the content-type, however,
128
- # the `X-UA-Compatible` response header should be send only for
133
+ # the `X-UA-Compatible` response header should be sent only for
129
134
# HTML documents and not for the other resources.
130
135
131
136
<FilesMatch "\.(appcache|atom|bbaw|bmp|br|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|gz|htc|ic[os]|jpe?g|m?js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|wasm|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$" >
@@ -134,19 +139,6 @@ Options -MultiViews
134
139
135
140
</IfModule >
136
141
137
- # ----------------------------------------------------------------------
138
- # | Iframes cookies |
139
- # ----------------------------------------------------------------------
140
-
141
- # Allow cookies to be set from iframes in Internet Explorer.
142
- #
143
- # https://msdn.microsoft.com/en-us/library/ms537343.aspx
144
- # https://www.w3.org/TR/2000/CR-P3P-20001215/
145
-
146
- # <IfModule mod_headers.c>
147
- # Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""
148
- # </IfModule>
149
-
150
142
# ######################################################################
151
143
# # MEDIA TYPES AND CHARACTER ENCODINGS #
152
144
# ######################################################################
@@ -346,11 +338,24 @@ AddDefaultCharset utf-8
346
338
# ----------------------------------------------------------------------
347
339
348
340
# Redirect from the `http://` to the `https://` version of the URL.
341
+ #
349
342
# https://wiki.apache.org/httpd/RewriteHTTPToHTTPS
350
343
344
+ # (1) If you're using cPanel AutoSSL or the Let's Encrypt webroot
345
+ # method it will fail to validate the certificate if validation
346
+ # requests are redirected to HTTPS. Turn on the condition(s)
347
+ # you need.
348
+ #
349
+ # https://www.iana.org/assignments/well-known-uris/well-known-uris.xhtml
350
+ # https://tools.ietf.org/html/draft-ietf-acme-acme-12
351
+
351
352
# <IfModule mod_rewrite.c>
352
353
# RewriteEngine On
353
354
# RewriteCond %{HTTPS} !=on
355
+ # # (1)
356
+ # # RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
357
+ # # RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[\w-]+$
358
+ # # RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
354
359
# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
355
360
# </IfModule>
356
361
@@ -368,7 +373,7 @@ AddDefaultCharset utf-8
368
373
#
369
374
# (!) NEVER USE BOTH WWW-RELATED RULES AT THE SAME TIME!
370
375
371
- # (1) The rule assume by default that both HTTP and HTTPS
376
+ # (1) The rule assumes by default that both HTTP and HTTPS
372
377
# environments are available for redirection.
373
378
# If your SSL certificate could not handle one of the domains
374
379
# used during redirection, you should turn the condition on.
@@ -397,7 +402,7 @@ AddDefaultCharset utf-8
397
402
#
398
403
# (!) NEVER USE BOTH WWW-RELATED RULES AT THE SAME TIME!
399
404
400
- # (1) The rule assume by default that both HTTP and HTTPS
405
+ # (1) The rule assumes by default that both HTTP and HTTPS
401
406
# environments are available for redirection.
402
407
# If your SSL certificate could not handle one of the domains
403
408
# used during redirection, you should turn the condition on.
@@ -451,6 +456,7 @@ AddDefaultCharset utf-8
451
456
# against more than just clickjacking attacks:
452
457
# https://cure53.de/xfo-clickjacking.pdf.
453
458
#
459
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
454
460
# https://tools.ietf.org/html/rfc7034
455
461
# https://blogs.msdn.microsoft.com/ieinternals/2010/03/30/combating-clickjacking-with-x-frame-options/
456
462
# https://www.owasp.org/index.php/Clickjacking
@@ -460,7 +466,7 @@ AddDefaultCharset utf-8
460
466
# Header set X-Frame-Options "DENY"
461
467
462
468
# # `mod_headers` cannot match based on the content-type, however,
463
- # # the `X-Frame-Options` response header should be send only for
469
+ # # the `X-Frame-Options` response header should be sent only for
464
470
# # HTML documents and not for the other resources.
465
471
466
472
# <FilesMatch "\.(appcache|atom|bbaw|bmp|br|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|gz|htc|ic[os]|jpe?g|m?js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|wasm|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
@@ -484,18 +490,19 @@ AddDefaultCharset utf-8
484
490
# That almost certainly won't work as-is for your website!
485
491
#
486
492
# To make things easier, you can use an online CSP header generator
487
- # such as: http ://cspisawesome.com/.
493
+ # such as: https ://www. cspisawesome.com/.
488
494
#
495
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
496
+ # https://www.w3.org/TR/CSP3/
489
497
# https://content-security-policy.com/
490
498
# https://www.html5rocks.com/en/tutorials/security/content-security-policy/
491
- # https://w3c.github.io/webappsec-csp/
492
499
493
500
# <IfModule mod_headers.c>
494
501
495
502
# Header set Content-Security-Policy "script-src 'self'; object-src 'self'"
496
503
497
504
# # `mod_headers` cannot match based on the content-type, however,
498
- # # the `Content-Security-Policy` response header should be send
505
+ # # the `Content-Security-Policy` response header should be sent
499
506
# # only for HTML documents and not for the other resources.
500
507
501
508
# <FilesMatch "\.(appcache|atom|bbaw|bmp|br|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|gz|htc|ic[os]|jpe?g|m?js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|wasm|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
@@ -598,12 +605,14 @@ AddDefaultCharset utf-8
598
605
# which can be done with either `env=https` or `"expr=%{HTTPS} == 'on'"` (4). The
599
606
# exact way depends on your environment and might just be tried.
600
607
#
601
- # https://www.html5rocks.com/en/tutorials/security/transport-layer-security/
602
- # https://tools.ietf.org/html/rfc6797#section-6.1
603
- # https://blogs.msdn.microsoft.com/ieinternals/2014/08/18/strict-transport-security/
604
608
# (2) https://hstspreload.org/
605
609
# (3) https://tools.ietf.org/html/rfc6797#section-7.2
606
610
# (4) https://stackoverflow.com/questions/24144552/how-to-set-hsts-header-from-htaccess-only-on-https/24145033#comment81632711_24145033
611
+ #
612
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
613
+ # https://tools.ietf.org/html/rfc6797#section-6.1
614
+ # https://www.html5rocks.com/en/tutorials/security/transport-layer-security/
615
+ # https://blogs.msdn.microsoft.com/ieinternals/2014/08/18/strict-transport-security/
607
616
608
617
# <IfModule mod_headers.c>
609
618
# Header always set Strict-Transport-Security "max-age=16070400; includeSubDomains"
@@ -624,9 +633,8 @@ AddDefaultCharset utf-8
624
633
# is serving user-uploaded content or content that could potentially be
625
634
# treated as executable by the browser.
626
635
#
627
- # https://www.slideshare.net/hasegawayosuke/owasp-hasegawa
636
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
628
637
# https://blogs.msdn.microsoft.com/ie/2008/07/02/ie8-security-part-v-comprehensive-protection/
629
- # https://msdn.microsoft.com/en-us/library/ie/gg622941.aspx
630
638
# https://mimesniff.spec.whatwg.org/
631
639
632
640
<IfModule mod_headers.c >
@@ -665,6 +673,7 @@ AddDefaultCharset utf-8
665
673
# you are taking all possible measures to prevent XSS attacks, the
666
674
# most obvious being: validating and sanitizing your website's inputs.
667
675
#
676
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
668
677
# https://blogs.msdn.microsoft.com/ie/2008/07/02/ie8-security-part-iv-the-xss-filter/
669
678
# https://blogs.msdn.microsoft.com/ieinternals/2011/01/31/controlling-the-xss-filter/
670
679
# https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
@@ -675,7 +684,7 @@ AddDefaultCharset utf-8
675
684
# Header set X-XSS-Protection "1; mode=block"
676
685
677
686
# # `mod_headers` cannot match based on the content-type, however,
678
- # # the `X-XSS-Protection` response header should be send only for
687
+ # # the `X-XSS-Protection` response header should be sent only for
679
688
# # HTML documents and not for the other resources.
680
689
681
690
# <FilesMatch "\.(appcache|atom|bbaw|bmp|br|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|gz|htc|ic[os]|jpe?g|m?js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|wasm|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
@@ -712,7 +721,7 @@ AddDefaultCharset utf-8
712
721
# Header set Referrer-Policy "no-referrer-when-downgrade"
713
722
714
723
# # `mod_headers` cannot match based on the content-type, however,
715
- # # the `Referrer-Policy` response header should be send
724
+ # # the `Referrer-Policy` response header should be sent
716
725
# # only for HTML documents and not for the other resources.
717
726
718
727
# <FilesMatch "\.(appcache|atom|bbaw|bmp|br|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|gz|htc|ic[os]|jpe?g|m?js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|wasm|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
@@ -721,6 +730,29 @@ AddDefaultCharset utf-8
721
730
722
731
# </IfModule>
723
732
733
+ # ----------------------------------------------------------------------
734
+ # | Disable TRACE HTTP Method |
735
+ # ----------------------------------------------------------------------
736
+
737
+ # Prevent Apache from responding to `TRACE` HTTP request.
738
+ #
739
+ # The TRACE method, while apparently harmless, can be successfully
740
+ # leveraged in some scenarios to steal legitimate users' credentials
741
+ #
742
+ # Modern browsers now prevent TRACE requests being made via JavaScript,
743
+ # however, other ways of sending TRACE requests with browsers have been
744
+ # discovered, such as using Java.
745
+ #
746
+ # (!) The `TraceEnable` directive will only work in the main server
747
+ # configuration file, so don't try to enable it in the `.htaccess` file!
748
+ #
749
+ # https://tools.ietf.org/html/rfc7231#section-4.3.8
750
+ # https://www.owasp.org/index.php/Cross_Site_Tracing
751
+ # https://www.owasp.org/index.php/Test_HTTP_Methods_(OTG-CONFIG-006)
752
+ # https://httpd.apache.org/docs/current/mod/core.html#traceenable
753
+
754
+ # TraceEnable Off
755
+
724
756
# ----------------------------------------------------------------------
725
757
# | Server-side technology information |
726
758
# ----------------------------------------------------------------------
@@ -768,7 +800,7 @@ ServerSignature Off
768
800
#
769
801
# https://httpd.apache.org/docs/current/mod/core.html#servertokens
770
802
771
- #ServerTokens Prod
803
+ # ServerTokens Prod
772
804
773
805
# ######################################################################
774
806
# # WEB PERFORMANCE #
@@ -781,7 +813,9 @@ ServerSignature Off
781
813
<IfModule mod_deflate.c >
782
814
783
815
# Force compression for mangled `Accept-Encoding` request headers
784
- # https://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html
816
+ #
817
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding
818
+ # https://calendar.perfplanet.com/2010/pushing-beyond-gzipping/
785
819
786
820
<IfModule mod_setenvif.c >
787
821
<IfModule mod_headers.c >
@@ -793,6 +827,7 @@ ServerSignature Off
793
827
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
794
828
795
829
# Compress all output labeled with one of the following media types.
830
+ #
796
831
# https://httpd.apache.org/docs/current/mod/mod_filter.html#addoutputfilterbytype
797
832
798
833
<IfModule mod_filter.c >
@@ -850,6 +885,7 @@ ServerSignature Off
850
885
# the response, and thus, wouldn't be able to understand the
851
886
# content.
852
887
#
888
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
853
889
# https://httpd.apache.org/docs/current/mod/mod_mime.html#addencoding
854
890
855
891
<IfModule mod_mime.c >
@@ -869,6 +905,10 @@ ServerSignature Off
869
905
# files by your own. Enabling this part will not auto-generate
870
906
# brotlied files.
871
907
#
908
+ # Note that some clients (eg. browsers) require a secure connection
909
+ # to request brotli-compressed resources.
910
+ # https://www.chromestatus.com/feature/5420797577396224
911
+ #
872
912
# https://httpd.apache.org/docs/current/mod/mod_brotli.html#precompressed
873
913
874
914
# <IfModule mod_headers.c>
@@ -977,6 +1017,7 @@ ServerSignature Off
977
1017
# used by mobile network providers) from modifying the website's
978
1018
# content.
979
1019
#
1020
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
980
1021
# https://tools.ietf.org/html/rfc2616#section-14.9.5
981
1022
#
982
1023
# (!) If you are using `mod_pagespeed`, please note that setting
@@ -997,6 +1038,7 @@ ServerSignature Off
997
1038
998
1039
# Remove `ETags` as resources are sent with far-future expires headers.
999
1040
#
1041
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
1000
1042
# https://developer.yahoo.com/performance/rules.html#etags
1001
1043
# https://tools.ietf.org/html/rfc7232#section-2.3
1002
1044
@@ -1008,15 +1050,17 @@ ServerSignature Off
1008
1050
FileETag None
1009
1051
1010
1052
# ----------------------------------------------------------------------
1011
- # | Expires headers |
1053
+ # | Cache expiration |
1012
1054
# ----------------------------------------------------------------------
1013
1055
1014
- # Serve resources with far-future expires headers .
1056
+ # Serve resources with far-future expiration date .
1015
1057
#
1016
1058
# (!) If you don't control versioning with filename-based
1017
1059
# cache busting, you should consider lowering the cache times
1018
1060
# to something like one week.
1019
1061
#
1062
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
1063
+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expires
1020
1064
# https://httpd.apache.org/docs/current/mod/mod_expires.html
1021
1065
1022
1066
<IfModule mod_expires.c >
@@ -1143,18 +1187,21 @@ FileETag None
1143
1187
# specified files.
1144
1188
1145
1189
# <IfModule mod_include.c>
1190
+
1146
1191
# <FilesMatch "\.combined\.js$">
1147
1192
# Options +Includes
1148
1193
# AddOutputFilterByType INCLUDES application/javascript \
1149
1194
# application/x-javascript \
1150
1195
# text/javascript
1151
1196
# SetOutputFilter INCLUDES
1152
1197
# </FilesMatch>
1198
+
1153
1199
# <FilesMatch "\.combined\.css$">
1154
1200
# Options +Includes
1155
1201
# AddOutputFilterByType INCLUDES text/css
1156
1202
# SetOutputFilter INCLUDES
1157
1203
# </FilesMatch>
1204
+
1158
1205
# </IfModule>
1159
1206
1160
1207
# ----------------------------------------------------------------------
@@ -1167,11 +1214,10 @@ FileETag None
1167
1214
#
1168
1215
# To understand why this is important and even a better solution than
1169
1216
# using something like `*.css?v231`, please see:
1170
- # http ://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
1217
+ # https ://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
1171
1218
1172
1219
# <IfModule mod_rewrite.c>
1173
1220
# RewriteEngine On
1174
1221
# RewriteCond %{REQUEST_FILENAME} !-f
1175
- # RewriteRule ^(.+)\.(\d +)\.(bmp|css|cur|gif|ico|jpe?g|m?js|png|svgz?|webp|webmanifest)$ $1.$3 [L]
1222
+ # RewriteRule ^(.+)\.(\w +)\.(bmp|css|cur|gif|ico|jpe?g|m?js|png|svgz?|webp|webmanifest)$ $1.$3 [L]
1176
1223
# </IfModule>
1177
-
0 commit comments