RewriteEngine On
# Skip existing files and directories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Redirect www and non-www HTTP to HTTPS
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^gateway2world\.com [NC]
RewriteRule ^ https://www.gateway2world.com%{REQUEST_URI} [L,R=301]

# # Redirect index.php to root
RewriteCond %{THE_REQUEST} /index [NC]
RewriteRule ^index / [R=301,L]
# Remove .php extension from URL
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ /$1.html [L]

# Redirect .php URLs to clean URLs
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html\s
RewriteRule ^ %1 [R=301,L]

RewriteCond %{HTTP_HOST} ^gateway2world.com [NC]
RewriteRule ^(.*)$ https://www.gateway2world.com/$1 [L,R=301]

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php80” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php80 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
