Slash Trailing

User 2907842 Photo


Registered User
42 posts

Hello,

I'm wanting to change the way my URL is displayed for instance
https://www.yoursitehere.com/about.html
to
https://www.yoursitehere.com/about/
or
https://www.yoursitehere.com/about

I’ve done some research, and found it has to do with folder structure within the root directory of the server, and some .htaccess editing. Although I’ve not concluded what I should do.
When exporting does folder structure matter (modular or flat) when trying to achieve the desired results?
Also, when referencing pages within RSD they are automatically identified as “about.html” is there something I possibly need to change when naming my pages?

Thanks

User 2903050 Photo


Registered User
260 posts

It's an easy fix in the htaccess file but I won't be able to look until tonight.
Regards Phil
User 2695940 Photo


Registered User
99 posts

Hi Daryl,
It's also easy to do if you can add a folder to your root directory named 'about' and then put your 'about.html' in that folder and simply rename the 'about.html' to index.html

The browsers always look for an 'index' file first so if you point them to the folder 'about' (or whatever name you give them) they look for the 'index' file to load.

Do the same for the other pages and you're all set.

Hope that helps,
John
John Ferguson
Website Design and Development
www.jf1.co
User 122279 Photo


Senior Advisor
13,163 posts
Online Now

I would not actually recommend the solution with a folder for each file. It sounds ok, but in real life it is very cumbersome, to say the least. I took over a site once with that setup, and editing the pages was a night mare! You couldn't open more than one index file at the time (this was in HTML Editor), because otherwise you would not know which index is which, and the risk of messing it up is imminent. In RSD or SD you would have to do this manually anyway, after export. And what if the site has a zillion of pages?

A .htaccess solution sounds better, but I don't know the actual details about it. Someone here will know, for sure.
Ha en riktig god dag!
Inger, Norway
My new honey site, built with RFF: https://eikweb.com/horgenhonning/
Component sharing for RFF, RBB, RSD and SD: https://eikweb.com/sharing/


User 84349 Photo


Registered User
65 posts

Using .htaccess would do a simple redirect provided the server is Apache. Not sure what alternatives are for other servers.
Russ
User 2839879 Photo


Registered User
99 posts

Here's my htaccess code for this...

# force redirect of html to no-extension
RewriteCond %{THE_REQUEST} ^GET\s.+\.html
RewriteRule ^(([^/]+/)*[^/.]+)\.html$ https://www.example.com/$1 [R=301,L]


Replace "https://www.example.com" with your website address.

I additionally recommend you redirect traffic to either the www or non-www address. Here's what I use to redirect from non-www to www.

# non-www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) https://www.example.com/$1 [R=301,L]


This is important for SEO (Search Engine Optimisation), so you're not splitting your traffic between the two versions.
CoffeeCup Websites:
City Church Christchurch: https://city.org.nz
Champion Freight: https://www.championfreight.co.nz/
eChamp: https://echamp.co.nz/
Champion Containers: http://championcontainersnz.com/
User 2695940 Photo


Registered User
99 posts

Inger wrote:
I would not actually recommend the solution with a folder for each file. It sounds ok, but in real life it is very cumbersome, to say the least. I took over a site once with that setup, and editing the pages was a night mare! You couldn't open more than one index file at the time (this was in HTML Editor), because otherwise you would not know which index is which, and the risk of messing it up is imminent. In RSD or SD you would have to do this manually anyway, after export. And what if the site has a zillion of pages?

A .htaccess solution sounds better, burt I don't know the actual details about it. Someone here will know, for sure.


I agree with Inger on this... I was just thinking if it was a simple few page site that would be one quick solution. htaccess file would be the best solution.

John
John Ferguson
Website Design and Development
www.jf1.co

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.