Question .htacess file - Post ID 272933

User 1869666 Photo


Registered User
229 posts

Wondering if there is a global .htaccess that will redirect all .htm files to .html files rather than listing all files?
User 103173 Photo


VP of Software Development
0 posts

Carolyn Borjon wrote:
Wondering if there is a global .htaccess that will redirect all .htm files to .html files rather than listing all files?

You could use something like this:

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.htm$ $1.html [R=permanent]
Learn the essentials with these quick tips for Responsive Site Designer, Responsive Email Designer, Foundation Framer, and the new Bootstrap Builder. You'll be making awesome, code-free responsive websites and newsletters like a boss.
User 1869666 Photo


Registered User
229 posts

So this would be a .htaccess file in the home directory? Nothing else needed in .htaccess? Just:
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.htm$ $1.html [R=permanent]

and save with Notepad as a txt file then remove the extension before FTPing to server?
User 122279 Photo


Senior Advisor
14,454 posts

I usually call the file htaccess.txt when editing locally and uploading. Then I change the file name directly on the server.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 1869666 Photo


Registered User
229 posts

Yes, thanks Inger. My FTP program will let me drop the .txt extension either locally or on the server. But I'm unsure about the content of the .htaccess file. Is it only
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.htm$ $1.html [R=permanent]

Nothing else goes in the .htaccess file?
User 2765857 Photo


Registered User
614 posts

Scott Swedorski wrote:
Carolyn Borjon wrote:
Wondering if there is a global .htaccess that will redirect all .htm files to .html files rather than listing all files?

You could use something like this:

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.htm$ $1.html [R=permanent]


Scott I tried that today and when I updated and uploaded my .htaccess file my site could not be found when I only kept 1st line RewriteEngine on and uploaded .htaccess again site back to working good again so am I doing it wrong?
Ray
Ray aka Kreations
Since 1994 Chocolate bar wrappers for all occasions.
Since 1972 helping clients help "Discover Their Dream Vacation"

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.