On my website, when somebody requests a directory, I want it to remove the ‘/’ and add ‘.html’ (minus the quotes, of course).
Example:
If someone goes to domain.com/directory/ it should redirect to domain.com/directory.html/ and the same should stand for: domain.com/another-directory/ should redirect to domain.com/another-directory.html.
I would like to place a line (or two) of code to my htaccess file that will make any directory (URL ending with /) redirect to URL.html (removing the / of course).
I would also like it to visually redirect, so the user will actually see it change to .html.
I’m quite a novice web programmer, and any help is greatly appreciated.
Note: I did use Redirect /directory /directory.html and that worked, but that requires a lot of extra coding, and I would much prefer one simple statement to cover all directories.
This is going to be a bit difficult with htaccess, I assume you want to do the following:
First one is straightforward:
Second part is tricky
However, if what you just have is a bunch of files called
directory.html,directory2.html,directory3.html, etc. and you want to make it so when someone enters http://domain.com/directory2/ into their address bar they get served the contents ofdirectory2.html, it will be much simpler: