[英]How to make ADSF/Puma serve HTML files without the .html extension
I am building a static site without the help of Jekyll or any other known static site builder. 我正在构建一个静态站点,没有Jekyll或任何其他已知静态站点构建器的帮助。 When deploying such site to a static site host like GitHub Pages or Netlify, these servers know to load
software.html
when I am accessing mydomain.com/software
(without the .html
extension). 将此类站点部署到静态站点主机(如GitHub Pages或Netlify)时,这些服务器知道在我访问
mydomain.com/software
(没有.html
扩展名)时加载software.html
。
Is there a way for me to reproduce this behavior when running a local, Ruby-based web server such as Puma? 在运行像Puma这样的本地基于Ruby的Web服务器时,有没有办法让我重现这种行为? More specifically, I am using Ruby's adsf wrapper to launch a Puma server to serve my site locally for development.
更具体地说,我使用Ruby的adsf包装器来启动Puma服务器以在本地为我的站点提供开发。
My guess is that this should be possible by some rack middleware or rack configuration, I am just unable to identify the proper Google search for it. 我的猜测是,这应该是一些机架中间件或机架配置,我只是无法识别正确的谷歌搜索它。
I should probably mention that I am not interested in the directory/index.html
approach, since all web servers I have seen add a trailing slash to the URL in these cases. 我应该提一下,我对
directory/index.html
方法不感兴趣,因为我看到的所有Web服务器都在这些情况下为URL添加了一个尾部斜杠。
https://github.com/tommysundstrom/middleman-rack-optional-html might help. https://github.com/tommysundstrom/middleman-rack-optional-html可能有所帮助。
actually the code is simple. 实际上代码很简单。 add ".html" extention if the path doesn't end with "html".
如果路径不以“html”结尾,则添加“.html”扩展名。
https://github.com/tommysundstrom/middleman-rack-optional-html/blob/df1e50beca7599f3e47c5b83887573434f3253e3/lib/rack/middleman/optional_html.rb#L50 https://github.com/tommysundstrom/middleman-rack-optional-html/blob/df1e50beca7599f3e47c5b83887573434f3253e3/lib/rack/middleman/optional_html.rb#L50
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.