我的应用程序在 Sinatra 上运行,并使用 Passenger 部署在我的 Apache Web 服务器上。我的目录结构如下:
approot
` public
` css
- bootstrap.css
` uploads
- empty.txt
` tmp
- restart.txt
` views
- success.haml
- upload.haml
- config.ru
- myapp.rb
内部 upload.haml
%link(rel="stylesheet" href="css/bootstrap.css")
当我在 localhost:4567 上运行这个应用程序时,CSS 加载得很好。但是,当我将它部署到我的 Web 服务器上时,CSS 不会加载。
在我的网络服务器上,使用以下方式访问应用程序:rubyapps.mydomain.com/appname
如果我输入:rubyapps.mydomain.com/appname/css/bootstrap.css
,我就能很好地看到我的 CSS 文件的内容。
完全困惑,不明白 Sinatra 如何处理这种情况,寻求一点帮助。
最佳答案
您可能需要使用 Sinatra 的 URL helper .
For generating URLs you should use the url helper method, for instance, in Haml:
%a{:href => url('/foo')} foo
It takes reverse proxies and Rack routers into account, if present.
This method is also aliased to to (see below for an example).
关于css - 我的 haml View 在部署时无法在我的 public/css 文件夹中找到 css 文件,但设法在本地主机上找到它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11453214/