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