<IfModule mod_rewrite.c>
    RewriteEngine On

    # Redirect www to non-www (optional)
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]

    # Handle clean URLs by rewriting requests to index.php
    RewriteRule ^(.*)$ public/$1 [L]

    # If the request is to a directory or file that exists, do nothing
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ public/index.php/$1 [L]

    # Set the default character encoding to UTF-8
    AddDefaultCharset UTF-8

    # Disable directory listing
    Options -Indexes

    # Prevent access to sensitive files and folders
    <FilesMatch "^\.">
        Order Deny,Allow
        Deny from all
    </FilesMatch>
    
    # Prevent access to .env file
    <Files .env>
        Order Deny,Allow
        Deny from all
    </Files>

    # Prevent access to .git files
    <Files ~ "\.git">
        Order Deny,Allow
        Deny from all
    </Files>
</IfModule>

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php82” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php82___lsphp .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
