How to redirect *.htm *,htm *,html to *.html in .htaccess?

by jasen_gottlieb , in category: Third Party Scripts , a month ago

How to redirect *.htm *,htm *,html to *.html in .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dana , a month ago

@jasen_gottlieb 

To redirect all variations of .htm and .html to .html in .htaccess, you can use the following code snippet:

1
2
3
RewriteEngine On
RewriteRule ^(.*).htm$ /$1.html [L,R=301]
RewriteRule ^(.*).htm(l)?$ /$1.html [L,R=301]


This code will redirect any URLs ending with .htm or .html to the corresponding .html version.


Make sure to test the redirection after adding this code to your .htaccess file to ensure it is working correctly.