RewriteEngine On

# Redirect all requests with a trailing slash to the same URL without the trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.*)/$ /$1 [R=301,L]

# Hide .html in URLs and serve files without extensions
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)/?$ $1.html [L]

# Redirect requests with .html to URLs without extensions
RewriteCond %{THE_REQUEST} \s/([^.]+)\.html [NC]
RewriteRule ^ /%1 [R=301,L]

# Check if the requested path is an existing directory or a file with .html or .php extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

# Redirect root path to index.html (or home.html)
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{DOCUMENT_ROOT}/home.html -f
RewriteRule ^$ /home.html [L]

# Disable directory indexing
Options -Indexes

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