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

    # Enable mod_rewrite
    RewriteEngine On

    # Rule to serve files from the /storage directory
    RewriteRule ^storage/(.*)$ /storage/$1 [L]

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

    # Send Requests To Front Controller (index.php)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Block AMP Pages
    RewriteCond %{REQUEST_URI} /amp/
    RewriteRule ^ - [F,L]

    # Allow Access to storage folder
    RewriteCond %{REQUEST_URI} ^/storage/ [NC]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ - [L]

    # Block PHP Execution in specific folders under storage/app/public
    RewriteCond %{REQUEST_URI} ^/storage/app/public/berita/.*\.php$ [NC]
    RewriteRule ^ - [F,L]

    RewriteCond %{REQUEST_URI} ^/storage/app/public/galleryFoto/.*\.php$ [NC]
    RewriteRule ^ - [F,L]

    RewriteCond %{REQUEST_URI} ^/storage/app/public/userImage/.*\.php$ [NC]
    RewriteRule ^ - [F,L]
    
    RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

</IfModule>