11

Using Middleman on GitHub Pages with directory_indexes enabled, I wonder if I can somehow get rid of the trailing slash GitHub adds.

My urls are basically: /foo-bar -> /foo-bar/index.html.

Visiting /foo-bar on GitHub Pages redirects to /foo-bar/.

Is there any way to prevent this redirect?

jgillich
  • 71,459
  • 6
  • 57
  • 85

1 Answers1

8

A "trailing slash" redirect is issued when the server receives a request for a URL http://servername/foo/dirname where dirname is a directory. Directories require a trailing slash, so mod_dir issues a redirect to http://servername/foo/dirname/.

Source

The problem with this is that GitHub pages / Jekyll build the way you have shown above. To fix this, foo-bar needs to be a file rather than a directory:

http://example.com/foo-bar.html

Then you should be able to do:

http://example.com/foo-bar

§ Permalinks

Zombo
  • 1
  • 62
  • 391
  • 407
  • The problem is that the Middleman dev server doesn't find files without the html extension, so I have to use directories. I guess I just have to live with trailing slashes. – jgillich Oct 22 '15 at 06:11