yholtz
yholtz

Reputation: 93

Remove trailing slash on GitHub page hosted website

I have a website that is now hosted on Github and works fine: https://www.r-graph-gallery.com

Unfortunately, that kind of URL ending with a slash does not work:

https://www.r-graph-gallery.com/heatmap/.

It redirects toward my 404.html file, but without the css loading.

Note that currently both https://www.r-graph-gallery.com/heatmap and

https://www.r-graph-gallery.com/heatmap.html work properly.

How can I make the slash ending URL work? It is crucial for me since google search always links to slash ending URLs...

I've tried to add a .htaccess file with redirection rules, but after some research it looks like this is not supported by gh pages.

Thanks for any hint or solution!

Upvotes: 5

Views: 1804

Answers (1)

Nathan Fries
Nathan Fries

Reputation: 1524

You can use a service like Cloudflare [https://www.cloudflare.com/] with GH Pages. They are completely free for a single site.

[https://dispiro.com/] is hosted on GH Pages and all traffic is routed through Cloudflare - and trailing slashes work just fine.

EDIT: Unfortunately there is not much available in the way of configuration on GH Pages. If you don't mind modifying your directory structure, you may be able to get it to work without a third party service.

When you go to https://www.r-graph-gallery.com GH Pages searches for index.html in your root directory. When you go to /heatmap Pages is looking for heatmap.html. When you go to /heatmap/ it is looking for a /heatmap/ directory. One solution would be to place another index.html file inside a /heatmap/ directory and Pages should find the file.

/index.html
/heatmap/index.html

The issue is known Apparently

Upvotes: 3

Related Questions