I am trying to get http_reply_from_files/3 from library(http/http_files) to first return a moved (301 Moved Permanently) reply in case the URL to a directory is missing the trailing /.
I was hoping to get this out of the box, since the documentation of http_reply_from_files/3 refers to http_reply_dirindex/3, where this behavior is described. However, the example in the documentation fails to show this behavior.
This is annoying, for example since relative links in index.html pages point to the wrong direction if the user omits the trailing /. Any hints on how to enable this behavior?
it seems this is not causing a lot of interest from the community, so I just went ahead and worked on it on my own. In case anybody stumbles over this thread in the future and is interested in the topic, please refer to the pull request shown on https://github.com/SWI-Prolog/packages-http/issues/142 for a fix.
Sorry, I should have added this in the first place… I modified to show what I mean: site2.pl (1.3 KB) From root you can click on sub to move to the subdirectory. This will take you to http://localhost:4000/sub (no trailing /) and serve sub/index.html. Now I modified sub/index.html to include a relative link to sub/file2.html. Clicking this link gives an internal server error. If I open http://localhost:4000/sub/ instead, the link works.