# =============================================================================
#  Innovio FlexKapG — PHP site (.htaccess for Apache / Namecheap shared hosting)
# =============================================================================

DirectoryIndex index.php

<IfModule mod_rewrite.c>
  RewriteEngine On
  # If the site is installed in a sub-directory, set the base accordingly:
  # RewriteBase /innovio/

  # Pretty URLs ---------------------------------------------------------
  # /services/<slug> -> /service.php?slug=<slug>
  RewriteRule ^services/([a-z0-9-]+)/?$ service.php?slug=$1 [L,QSA]

  # /workflow, /imprint, /privacy, /terms, /contact -> matching .php file
  RewriteRule ^(workflow|imprint|privacy|terms|contact)/?$ $1.php [L,QSA]

  # If the request is a real file or directory, serve it as-is.
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^ - [L]
</IfModule>

# Force HTTPS (uncomment after your SSL certificate is active) ----------------
# <IfModule mod_rewrite.c>
#   RewriteEngine On
#   RewriteCond %{HTTPS} !=on
#   RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# </IfModule>

# Compression -----------------------------------------------------------------
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
  AddOutputFilterByType DEFLATE application/javascript application/json
  AddOutputFilterByType DEFLATE image/svg+xml font/woff font/woff2
</IfModule>

# Caching ---------------------------------------------------------------------
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 month"
  ExpiresByType text/html "access plus 0 seconds"
  ExpiresByType text/css  "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
</IfModule>

<IfModule mod_headers.c>
  Header set X-Content-Type-Options "nosniff"
  Header set X-Frame-Options "SAMEORIGIN"
  Header set Referrer-Policy "strict-origin-when-cross-origin"
  Header set Permissions-Policy "geolocation=(), microphone=(), camera=()"
</IfModule>

# Block direct web access to includes/ and lib/ -------------------------------
<IfModule mod_rewrite.c>
  RewriteRule ^(includes|lib)/ - [F,L]
</IfModule>

# Hide dotfiles
<FilesMatch "^\.">
  Require all denied
</FilesMatch>

# Make sure config.php is never served as text
<FilesMatch "^config\.php$">
  Require all granted
</FilesMatch>
