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

by jasen_gottlieb , in category: Third Party Scripts , 8 months ago

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

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dana , 8 months 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.

Related Threads:

How to remove .php .html via .htaccess?
How to redirect custom html site to wordpress?
How to allow execution of php in html file using .htaccess?
How align elements in a html table?
How to prevent html injection in fastapi?
How to remove html tags from an html string using regex?