I just came up with an idea. Instead of using an .htaccess
file to remove .html
from the URL, why not just use a simple folder structure and in each folder add an index.html
?
For instance:
example.com/index.html
→ Homeexample.com/about/index.html
→ About
Now simply use a hyperlink on the homepage to the about folder, since typically index.html
files are opened automatically.
The upside of this kind of navigation, is that it would be easily possible to create sub pages with no crazy database / .htaccess
setup.
Now my question is: is there any reason not to create a webpage like that and is it legitimate to use multiple index.html
files?
I appreciate all the help.
2
Answers
With the
index.html
route, there would be three URL’s that can access the same page. For example for an about page:www.yourwebsite.com/about
www.yourwebsite.com/about/
www.yourwebsite.com/about/index.html
Using the
.htaccess
file would likely give you more benefit from an SEO perspective. You can tell the search engine which one to use, by using 301 redirects. See more about how Google does this here:https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html
Of course you could set up your website using folders and index.html’s, and still
use the
.htaccess
file to take care of the SEO. But, depending on your sites size and structure, this might be more work.The only downsides would be having to create a folder in addition to a file whenever you want to create a new page, and having to take more time to navigate into a folder in order to edit a page.
As long as you are using Apache, or a similar server software, multiple index files will function normally and be served from each folder.