How Do I Redirect "website/page" To "website/page.html" When People Type It In Browser (pretty-url)

- 1 answer

I recently started using a static site with without a cms. It's a basic website I uploaded and is only html/js/css.

When people type "" they get 404 not found. When they type "" they get the correct page.

How can I fix my site so users can simply type "website/page" and not be forced to type "website/page.html" without using php?


After researching the information about .htaccess files provided by @Gijsberts (thank you), I did the following:

  1. Created a .htaccess file on server.
  2. Added the following code:

    # Remove the .html extension from html files
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^.]+)$ $1.html [NC,L]



Most CMS systems have a .htaccess file what handles the redirect and the 404 errors. In CMS system they are most called "Pretty-urls". Read the links below to set up those pretty urls yourself with a static web page without a cms.