Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: undocumented ServeFile index.html redirect behavior #9876

laszlothewiz opened this issue Feb 14, 2015 · 3 comments


None yet
4 participants
Copy link

commented Feb 14, 2015

After an hour of head scratching and cursing and found that there's a strange way how ServeFile handles any path's that end with index.html:

  • Instead of serving the file directly it generates a 301 redirect response to the nearest folder


this redirects to /public/blog/

This is not mentioned in the documentation and could cause undesirable behavior.

I tried to add the note about it to the documentation but got rejected because apparently Go doesn't use Github's pull request system. So I don't know how to get this into the documentation so that others won't get tripped over it.

I would actually propose that "feature" to be removed because it's based on an arbitrary of considering the trailing slash ("/") to be the equivalent of a reference to "index.html".


This comment has been minimized.

Copy link

commented Feb 15, 2015

Docs to contribute a patch for review are at:

We should just document it so we're not changing behavior. IIRC, @rsc likes (and implemented) the current behavior. I don't have much preference either way, except for I prefer things not to change. Documenting it is fine.

@bradfitz bradfitz added this to the Go1.5 milestone Feb 15, 2015

@bradfitz bradfitz changed the title Undocumented Behavior of ServeFile in net/http package net/http: undocumented ServeFile index.html redirect behavior Feb 15, 2015


This comment has been minimized.

Copy link

commented Feb 15, 2015

Thank you!

I would like to update the docs but the contribution process is very complex! I'm totally confused after looking at it.

Is there a simple way to submit a change for review?


This comment has been minimized.

Copy link

commented Feb 16, 2015

That's the process. The document looks a lot more complicated than it is, because we made the instructions very thorough. Try following it through. It should take you around 10 minutes, or less.

@bradfitz bradfitz closed this in 125ed11 Apr 30, 2015

@golang golang locked and limited conversation to collaborators Jun 25, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.