- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘Other’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hi,
This may be a silly question, or I feel at any rate that the answer should be more obvious, but I am wondering how to set up a site so that the links do not include the “.html” file extension. I.e.:
mysite.com/blog
and not:
mysite.com/blog.html
I’ve previously been developing within WordPress and so this happened automatically, but how does one do this for a stand alone site. Some methods that I’ve come across already are: setup a series of folders each with their own index.html files, or add the following lines to .htaccess:
RewriteEngine on
RewriteBase /
RewriteRule ^(.+).html$ $1 [L,NC,R=301]
Do people here have a sense of what’s the best method?
It would be cleaner to just use HTACCESS.
You would do this in the htaccess file.
RewriteEngine On
# Redirect to HTML if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
@AlexHackney: Thanks! I will give this a try.