﻿# ==============================================================================
# PayWith - cPanel & Apache Configuration (.htaccess)
# ==============================================================================

# 1. Enable Rewrite Engine
<IfModule mod_rewrite.c>
    RewriteEngine On

    # Automatically force HTTPS on remote servers (Required for Web Crypto API & PWA)
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} !^localhost [NC]
    RewriteCond %{HTTP_HOST} !^127\.0\.0\.1 [NC]
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Map /api/xxx to /api/xxx.php if file exists
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ $1.php [L,QSA]
</IfModule>

# 2. MIME Types
<IfModule mod_mime.c>
    AddType application/manifest+json .webmanifest .json
    AddType image/svg+xml .svg
    AddType font/woff2 .woff2
</IfModule>

# 3. Security & Encoding Headers
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
</IfModule>

AddDefaultCharset UTF-8
