Hello,
We have sent out a printed leaflet containing the link to our “join” page shown without the “.html” extension. People typing in the link to visit the page receive a 404 error.
I could remove “.html” from the file name on the server, but that would mean changing other links that point to the full URL. Is there a way to overcome this so that both “https://www.xxxx.xxx/join.html” and “https://www.xxxx.xxx/join” will work?
Grateful for any advice.
If a uploaded a duplicate of “join.html” to the server without the “.html” extensions, so that I have both "join.html” and “join” files on the server, would that work?
Tony
You can keep “join.html” so your other links can still point to it, but also create a folder on the site called “join” and put a file, “index.html” in that folder.
index.html should have whatever is on join.html
Because it is in a folder, some image or other asset links may need to be updated.
Then I believe the browser with the incomplete address will try “https://www.xxxx.xxx/join/” which is the same as “https://www.xxxx.xxx/join/index.html”.
Thank you, that’s helpful.
If you’re using Apache server, this may help you or get you started. Place in your (or create) .htaccess file:
RewriteEngine On
RewriteRule ^join$ join.html [L]
To remove html file extension https://example.com/page.html
To https://example.com/page`
Add the following to the .htaccess file in the root directory
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC, L]
Or more simple:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html