RewriteEngine On

# Force HTTPS for all connections
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{HTTP_HOST} ^accsmsverify\.ng$ [OR]
RewriteCond %{HTTP_HOST} ^www\.accsmsverify\.ng$
RewriteRule ^/?$ "https://accsmsverify.ng/" [R=301,L]

# Enable GZIP compression for faster load times
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript application/javascript application/json
</IfModule>

# Set caching headers for static content to improve load speed
<IfModule mod_expires.c>
    ExpiresActive on
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType text/javascript "access plus 1 month"
    ExpiresByType application/x-javascript "access plus 1 month"
</IfModule>

# Enable browser caching
<IfModule mod_headers.c>
    Header set Cache-Control "max-age=31536000, public"
    Header set Expires "Thu, 15 Apr 2025 20:00:00 GMT"
</IfModule>

# Handle 404 errors
ErrorDocument 404 /404.php

# Optimize PHP handling (use the most efficient version of PHP)
<IfModule mime_module>
    AddHandler application/x-httpd-ea-php81 .php .php8 .phtml
</IfModule>

# Prevent PHP file browsing in directories
Options -Indexes

# Rewrite URL to add .php extension if file exists
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

# End of optimized .htaccess file

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