Monday , February 3 2025

How to open html pages without .html

If your site uses links like http://domain.com/testpage.html and http://domain.com/demo.html, and you want them to open like http://domain.com/testpage and http://domain.com/demo, you can use this solution.

Go through FTP or a File Manager to the folder with the site files. Open file .htaccess and add the following code:

RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+)\.html\ HTTP
RewriteRule ^([^.]+)\.html$ domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule (.*) /$1.html

where instead of domain.com use your domain name.

If file .htaccess (don’t forget to put a dot before the file name!) does not exist on the server, you can create it and paste the code from the example above with editing the domain name.

About iryna

I'm Iryna, a web developer from Ukraine with a decade of experience solving complex technical challenges in the world of freelance. Throughout my career, I've worked on everything from troubleshooting server-side issues and optimizing website performance to enhancing user interfaces. On this blog, I share detailed solutions to the technical problems I’ve encountered and methods that have worked best for me. In addition to my technical expertise, I’m also passionate about digital drawing. I hope the tutorials and insights I provide here will help both fellow developers and creatives alike in their own projects.

Check Also

Display the date + a few days from the current one

The task in short: you need to make the delivery date + 5 days from …

Leave a Reply

Your email address will not be published. Required fields are marked *