<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/public/?$
    RewriteRule ^(.*)$ / [R=301,L]
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Redirect HTTP to HTTPS
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

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

<IfModule mod_headers.c>
    # Hide unnecessary server info
    Header always unset X-Powered-By
    Header always unset Server

    # Clickjacking protection
    Header always set X-Frame-Options "SAMEORIGIN"

    # MIME-type sniffing protection
    Header always set X-Content-Type-Options "nosniff"

    # Referrer policy
    Header always set Referrer-Policy "strict-origin-when-cross-origin"

    # Permissions policy
    Header always set Permissions-Policy "geolocation=(), microphone=()"

    # Content Security Policy (basic setup, you can customize more in middleware)
    Header always set Content-Security-Policy "default-src 'self';"
</IfModule>

# Disable Apache server signature
ServerSignature Off


<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Redirect /index.php to clean URL
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php[^\s]* [NC]
    RewriteRule ^index\.php(?:/(.*))?$ /$1 [R=301,L]

    # Handle URLs without index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L]
</IfModule>



