# The Budgen Partnership - demo site (/demo/)
DirectoryIndex index.html
ErrorDocument 404 /demo/404.html
Options -Indexes

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /demo/

# Send all visitors to HTTPS (needs an SSL certificate - cPanel AutoSSL is fine)
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Permanent redirects from the old .html page addresses
RewriteRule ^about-us\.html$ about-us/ [R=301,L]
RewriteRule ^contact-us\.html$ contact-us/ [R=301,L]
RewriteRule ^services\.html$ services/ [R=301,L]
RewriteRule ^recruitment\.html$ recruitment/ [R=301,L]
RewriteRule ^privacy-policy\.html$ privacy-policy/ [R=301,L]
RewriteRule ^acacia-road\.html$ projects/acacia-road/ [R=301,L]
RewriteRule ^ark-conway\.html$ projects/ark-conway/ [R=301,L]
RewriteRule ^bentinck-school\.html$ projects/bentinck-school/ [R=301,L]
RewriteRule ^bishops-justus-school\.html$ projects/bishops-justus-school/ [R=301,L]
RewriteRule ^bramley-road\.html$ projects/bramley-road/ [R=301,L]
RewriteRule ^clerkenwell-road\.html$ projects/clerkenwell-road/ [R=301,L]
RewriteRule ^downham-road\.html$ projects/downham-road/ [R=301,L]
RewriteRule ^farnburn-avenue\.html$ projects/farnburn-avenue/ [R=301,L]
RewriteRule ^haydon-school\.html$ projects/haydon-school/ [R=301,L]
RewriteRule ^higgins-headquarters\.html$ projects/higgins-headquarters/ [R=301,L]
RewriteRule ^hillingdon-house\.html$ projects/hillingdon-house/ [R=301,L]
RewriteRule ^holland-park\.html$ projects/holland-park/ [R=301,L]
RewriteRule ^holly-house-hospital\.html$ projects/holly-house-hospital/ [R=301,L]
RewriteRule ^honourable-artillery\.html$ projects/honourable-artillery/ [R=301,L]
RewriteRule ^lake-house\.html$ projects/lake-house/ [R=301,L]
RewriteRule ^mark-hall-school\.html$ projects/mark-hall-school/ [R=301,L]
RewriteRule ^mill-road\.html$ projects/mill-road/ [R=301,L]
RewriteRule ^park-lane\.html$ projects/park-lane/ [R=301,L]
RewriteRule ^park-village-east\.html$ projects/park-village-east/ [R=301,L]
RewriteRule ^pollen-street\.html$ projects/pollen-street/ [R=301,L]
RewriteRule ^redington-road\.html$ projects/redington-road/ [R=301,L]
RewriteRule ^st-josephs-school\.html$ projects/st-josephs-school/ [R=301,L]
RewriteRule ^staines-road\.html$ projects/staines-road/ [R=301,L]
RewriteRule ^station-grove\.html$ projects/station-grove/ [R=301,L]
</IfModule>

# Keep internal files private
<FilesMatch "^(README\.txt|config\.php)$">
  Require all denied
</FilesMatch>
RedirectMatch 404 ^/demo/_go-live/

<IfModule mod_headers.c>
  # DEMO ONLY: stop search engines indexing the preview. Remove this line on the live site.
  Header always set X-Robots-Tag "noindex, nofollow"

  Header always set X-Content-Type-Options "nosniff"
  Header always set X-Frame-Options "SAMEORIGIN"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
  Header always set Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=()"
  Header always set Strict-Transport-Security "max-age=31536000" "expr=%{HTTPS} == 'on'"
  Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; form-action 'self'; frame-ancestors 'self'; base-uri 'self'; object-src 'none'"

  # Next.js build files have unique names, so they can be cached for a year
  <FilesMatch "\.(js|css|woff2?)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
  <FilesMatch "\.(jpe?g|png|webp|svg|ico)$">
    Header set Cache-Control "public, max-age=2592000"
  </FilesMatch>
  <FilesMatch "\.(html|txt)$">
    Header set Cache-Control "no-cache"
  </FilesMatch>
</IfModule>

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/javascript text/javascript application/json application/xml image/svg+xml
</IfModule>
