Internal links change to *.html after code export

Hello everyone!
The question is simple:

When on Webflow hosting, I’m referring to internal pages as ‘/pagename’ which works perfectly fine.
After exporting the code, though, all the links automatically change to ‘pagename.html’ which looks unprofessional when hosting externally.

Any ideas how to prevent this from happening?

Thanks,
Denis

Hey @denisbondar. I believe you can do this by creating an .htaccess file.

  1. Open Notepad and paste the following code:
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.*)$ $1.html

  2. Save the file as “.htaccess” without the quotes.

  3. Upload to your public_html folder at your host and rename your page files to remove the “.html”.

Let me know if that works for you!

More information .htaccess - How to remove .html from URL? - Stack Overflow

Thanks @jordanshotwell @samliew!

.htaccess is not ideal solution in my case, as I’m using Gituhb Pages, which only supports static content (so .htaccess won’t work there)

Any ideas on 1) how to prevent Webflow from adding ‘.html’ to the links (in the process of export) in first place?; or 2) how to automatically remove/replace ‘.html’ part from the body of html document on load to avoid removing it manually?

UDT: just fixed it using this script:

$(“body”).html($(“body”).html().replace(/.html/g,‘’));
$(“body”).html($(“body”).html().replace(/index.html/g,‘/’));

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.