H
H
Have you got any problems?2022-03-28 10:35:06
Layout
Have you got any problems?, 2022-03-28 10:35:06

How to remove .html from the end of the address of each web page of the site?

I tried to remove .html using the .htaccess file, but due to some commands, the site either stopped working or simply removed index.html, and left shop.html and other pages ...

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Vladimir Korotenko, 2022-03-28
@firedragon

site.com -> home
site.com/about -> home/about/index.html
and so on

N
Nadim Zakirov, 2022-03-28
@zkrvndm

Place on the page:

<script> history.replaceState('', '', location.pathname.replace(/\.html$/i, '')); </script>

This will remove the .html at the end, BUT if you try to refresh the page afterwards, it will fail.

K
Kvason, 2022-03-28
@Kvason

You make a folder in the main directory for each page like main -> second_page -> index.html and to go to the second page you enter an address like url.com/second_page

A
Alexander Falaleev, 2022-03-28
@suffix_ixbt

Religion does not allow you to use the service search?
https://qna.habr.com/q/78158
PS
In addition, there is nothing harmful for SEO or ugly in ".html" :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question