# Disable the pattern matching based on filenames
Options -MultiViews



<IfModule mod_rewrite.c>
  RewriteEngine On
  # Enable FollowSymLinks
  Options +FollowSymlinks
</IfModule>



<IfModule mod_autoindex.c>
  # Disable directory listings
  Options -Indexes
</IfModule>



AddDefaultCharset utf-8



<IfModule mod_mime.c>
  # Serve resources with the proper media types (from h5bp)
  AddType application/atom+xml                    atom
  AddType application/rss+xml                     rss
  AddType application/rdf+xml                     rdf
  AddType application/xml                         xml

  AddType text/javascript                         js mjs
  AddType application/json                        json map topojson
  AddType application/ld+json                     jsonld

  AddType application/manifest+json               webmanifest
  AddType application/x-web-app-manifest+json     webapp
  AddType text/cache-manifest                     appcache

  AddType audio/mp4                               f4a f4b m4a
  AddType audio/ogg                               oga ogg opus

  AddType video/mp4                               f4v f4p m4v mp4
  AddType video/ogg                               ogv
  AddType video/webm                              webm
  AddType video/x-flv                             flv

  AddType image/bmp                               bmp
  AddType image/svg+xml                           svg svgz
  AddType image/webp                              webp
  AddType image/x-icon                            cur ico

  AddType font/woff                               woff
  AddType font/woff2                              woff2
  AddType application/vnd.ms-fontobject           eot
  AddType font/ttf                                ttf
  AddType font/collection                         ttc
  AddType font/otf                                otf

  AddType text/calendar                           ics
  AddType text/markdown                           markdown md
  AddType text/vcard                              vcard vcf



  # Serve the following file types with a UTF-8 charset (from h5bp)
  AddCharset utf-8 .appcache \
                   .css \
                   .ics \
                   .js \
                   .json \
                   .manifest \
                   .markdown \
                   .md \
                   .mjs \
                   .rdf \
                   .rss \
                   .vcard \
                   .vcf \
                   .webapp \
                   .webmanifest \
                   .xml
</IfModule>



# @if NODE_ENV='production'
<IfModule mod_rewrite.c>
  # Ensure www on all URLs
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

  # Ensure https
  RewriteCond %{HTTPS} !=on
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# @endif



<IfModule mod_headers.c>
  # Opt out of Google FLoC
  Header always set Permissions-Policy: interest-cohort=()
  # Remove the X-Powered-By response header
  Header unset X-Powered-By
</IfModule>



# Prevent Apache from adding server info
ServerSignature Off



<IfModule mod_deflate.c>
  # Force compression for mangled `Accept-Encoding` request headers (from h5bp)
  <IfModule mod_setenvif.c>
    <IfModule mod_headers.c>
      SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
      RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
    </IfModule>
  </IfModule>



  # Compress all output labeled with one of the following media types (from h5bp)
  <IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE "application/atom+xml" \
                                  "application/javascript" \
                                  "application/json" \
                                  "application/ld+json" \
                                  "application/manifest+json" \
                                  "application/rdf+xml" \
                                  "application/rss+xml" \
                                  "application/schema+json" \
                                  "application/vnd.geo+json" \
                                  "application/vnd.ms-fontobject" \
                                  "application/x-font-ttf" \
                                  "application/x-javascript" \
                                  "application/x-web-app-manifest+json" \
                                  "application/xhtml+xml" \
                                  "application/xml" \
                                  "font/eot" \
                                  "font/opentype" \
                                  "image/bmp" \
                                  "image/svg+xml" \
                                  "image/vnd.microsoft.icon" \
                                  "image/x-icon" \
                                  "text/cache-manifest" \
                                  "text/css" \
                                  "text/html" \
                                  "text/javascript" \
                                  "text/plain" \
                                  "text/vcard" \
                                  "text/vnd.rim.location.xloc" \
                                  "text/vtt" \
                                  "text/x-component" \
                                  "text/x-cross-domain-policy" \
                                  "text/xml"
  </IfModule>



  # Serve gzipped SVGs correctly (from h5bp)
  <IfModule mod_mime.c>
    AddEncoding gzip      svgz
  </IfModule>

</IfModule>



<IfModule mod_rewrite.c>
  # Send would-be 404 requests to Craft
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
  RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>
