Back in the early 2000s — and before — most web page addresses ended in the .html extension. That’s not the case anymore, and I wanted to remove the .html extension from the URLs on a particular site. How do you do that with WordPress?
Here’s a case history — and the answer.
EmptyMirrorBooks.com was first built with html/css in 2000. When it was rebuilt with WordPress in 2012, the .html extension on the pages were kept in the interest of keeping the same URLs.
Now it’s 2017, and I wanted to get rid of those .html extensions. (It looks cleaner that way, and the “.html” serve no real purpose anymore.)
The site’s old permalink structure was
I needed to change it to
And then, so the old .html addresses wouldn’t return 404 errors, I needed to 301 redirect the old .html addresses to the new extensionless ones.
Turns out that it’s easy to do. Here’s how.
First, open .htaccess for editing
You’ll want to have this file open and ready to go. Access it with CPanel’s file editor, or via FTP.
In WordPress Admin, go to Settings –> Permalinks.
Select “plain.” Scroll down and save.
Now, select “custom.” Input
Then, scroll down and click “save.”
Put this in your .htaccess, above the WordPress rules. (Don’t forget to replace example.com with your own domain name.)
RewriteRule (.+)\.html?$ https://www.emptymirrorbooks.com/$1/ [R=301,L]
Then save your .htaccess.
Now your URLs should not be showing .html on the end of them — and the old addresses will automatically 301 redirect to the new.