# ROOT: /public_html/.htaccess

<IfModule mime_module>
  AddHandler application/x-httpd-ea-php81 .php .phtml
</IfModule>

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # Disable directory listing and content negotiation
  <IfModule mod_negotiation.c>
    Options -MultiViews -Indexes
  </IfModule>
  Options +FollowSymLinks

  # Serve static assets from /public
  RewriteRule ^(web_front|assets|css|js|images|fonts|vendor|storage|build|uploads)/(.*)$ public/$1/$2 [L,NC]

  # Serve favicon directly from uploads
  RewriteRule ^favicon\.ico$ public/uploads/hospital_content/favicon.ico [L,NC]

  # Don't rewrite existing files or directories
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^ - [L]

  # Route all other requests to Laravel's front controller
  RewriteCond %{REQUEST_URI} !^/public/
  RewriteRule ^ public/index.php [L,QSA]
</IfModule>

# MIME types for fonts
<IfModule mod_mime.c>
  AddType application/font-woff2 .woff2
  AddType application/font-woff .woff
  AddType application/vnd.ms-fontobject .eot
  AddType font/ttf .ttf
  AddType font/otf .otf
</IfModule>

# CORS headers for fonts
<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|otf|eot|woff|woff2)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>
