First check if you already have an .htaccess file. Since that’s typically a hidden file, you have to use whatever commands your FTP program has to display hidden files (or in the file manager in the control panel of yoour website).

If you already have an .htaccess file, great, download it and edit it in a plain text editor like Notepad.

Otherwise create a new text document in a plain text editor like Notepad and at the end save it with the name .htaccess.

Keep these directives together in your .htaccess file. Replace example.com with your own domain, and index.html with your own index page (which could be whatever your homepage actually is, e.g. home.html or index.php, etc):

###### This group will not be needed by most websites - try without it first
### add a missing trailing slash to end of domain name or folder name
### ONLY in case the server does not compensate for it
### ONLY use it if needed - othewise remove this block of directives.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.example.com/$1/ [L,R=301]

###### This group will not be needed by most websites - try without it first
### add a missing trailing slash to end of domain name or folder name
### ONLY in case the server does not compensate for it
### ONLY use it if needed - othewise remove this block of directives.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://example.com/$1/ [L,R=301]

Now don’t forget to make sure all the links on your site are consistent with this (don’t mix and match www and non-www links) and don’t use index.html (or whatever your homepage is) – instead use the root url (as “http://www.example.com/” or “http://example.com/” as per choice).

Or if you prefer all links on your site are just relative (no domain specified) and the homepage is just “/” .

These .htaccess directives will also help with links to the index page of a subfolder, exactly the same way as links to the index page of the site.

So the index page of a folder is “/foldername/” (i.e. relative to the root of the site).