# NeuroControls — server settings for neurocontrols.io (web root)
Options -Indexes
# index.php first: every page is a .php file that pulls in the shared header and footer from /includes/
DirectoryIndex index.php index.html
ErrorDocument 404 /404.php

<IfModule mod_rewrite.c>
RewriteEngine On
# force https + no www
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://neurocontrols.io%{REQUEST_URI} [L,R=301]
# an old address ending in index.html goes to the clean folder address (not inside the blog)
RewriteCond %{THE_REQUEST} \s/+(?:[^?\s]*/)?index\.html[\s?] [NC]
RewriteCond %{REQUEST_URI} !^/en/blog/ [NC]
RewriteRule ^((?:.*/)?)index\.html$ /$1 [L,R=301]
# pages that were removed
RewriteRule ^en/technology/neuromorphic-computing/?$ /en/technology/ [L,R=301]
RewriteRule ^de/technologie/neuromorphes-computing/?$ /de/technologie/ [L,R=301]
# old WordPress pages -> new pages
RewriteRule ^about-us/?$ /de/unternehmen/ [L,R=301]
RewriteRule ^contact-us/?$ /de/kontakt/ [L,R=301]
RewriteRule ^legal-notice/?$ /de/impressum/ [L,R=301]
RewriteRule ^privacy-policy/?$ /de/datenschutz/ [L,R=301]
RewriteRule ^research-publications/?$ /de/forschung/ [L,R=301]
# the WordPress blog lives in /en/blog/ (its own .htaccess there); the German blog address forwards to it
RewriteRule ^de/blog/?$ /en/blog/ [L,R=301]
</IfModule>

<IfModule mod_headers.c>
Header always set X-Content-Type-Options "nosniff"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()"
# pictures, fonts and videos never change under the same name: keep them in the browser for a year
<FilesMatch "\.(woff2|webp|png|jpg|jpeg|svg|mp3|mp4|ico)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
# styles and scripts carry a version number (?v=...), so they can be kept for a month
<FilesMatch "\.(css|js)$">
Header set Cache-Control "public, max-age=2592000"
</FilesMatch>
</IfModule>

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css application/javascript image/svg+xml application/xml text/plain application/json
</IfModule>
AddType font/woff2 .woff2
AddType image/webp .webp
AddType video/mp4 .mp4
