Remove HTML, add / and activate PHP 8 (adjusted)

I tested the code used in the .htaccess below and it worked perfectly.

RewriteEngine On

#301 from example.com/page.html to example.com/page
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]

# php -- BEGIN cPanel-generated handler, do not edit
# Defina o pacote “ea-php80” como a linguagem padrão de programação “PHP”.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php80 .php .php8 .phtml
</IfModule>

# php -- END cPanel-generated handler, do not edit
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{HTTP_HOST} ^yoursite\.com\.br$ [OR]
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com\.br$
RewriteRule ^/?$ "https\:\/\/yoursite\.com\.br\/" [R=301,L]

#Add the slash (/) at the end of the URL address
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteRule . %{REQUEST_URI}/ [L,R=301]

#Redirect pages without extension internally to the corresponding file
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*?)/?$ $1.html [L]
1 Like