Removing .html file extension from URL?

Hey @cyberdave,

After spending almost all of yesterday trying to solve this I was able to fix my problem. Here’s the solution for anyone who is having the same problem as I did:

  1. After exporting your webflow code, go through your entire codebase and change every href that has an .html file extension to not have any extension at all. So “index.html” becomes “index”. A quick way to do this is open every HTML file in Sublime Text, use “Find in File” (Cmd + Shift + F), and find “.html” and replace with “” (empty string).

  2. Now in your public_html file, create an .htaccess file if not already created. Then make sure the top of the file begins with:
    RewriteEngine on

  3. Add this code underneath the previous:
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^\.]+)$ $1.html [NC,L]

5 Likes