4

I am developing a website for myself, pure and without server language.

The urls are as they are called in the a tag, for example: blog / index.html.

Is there anything I can use to change that? I don't want to have to use framework. I would like to know if there is any tool that does this.

What I want to change is the ending. I don't want the extension to appear, just the route

GobsRuiz
  • 512
  • 1
  • 4
  • 14

1 Answers1

6

try create .htaccess file on your root folder then paste this

#remove html file extension-e.g. https://example.com/file.html will become https://example.com/file
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]

you can read more about this here https://www.plothost.com/kb/how-to-remove-php-html-extensions-with-htaccess/

EDIT

Since you are using Vercel.com, as per their documentation there's a file config named vercel.json you can add this

{
  "cleanUrls": true
}

the docs said,

When set to true, all HTML files and Serverless Functions will have their extension removed. When visiting a path that ends with the extension, a 308 response will redirect the client to the extensionless path.

for more information pls read their docs here https://vercel.com/docs/configuration#project/clean-urls

naoval luthfi
  • 703
  • 7
  • 20