0

我的应用程序在 Sinatra 上运行,并使用Passenger 部署在我的 Apache Web 服务器上。我的目录结构如下:

approot
` public
  ` css
    - bootstrap.css
  ` uploads
    - empty.txt
` tmp
  - restart.txt
` views
  - success.haml
  - upload.haml
- config.ru
- myapp.rb

内部上传.haml

%link(rel="stylesheet" href="css/bootstrap.css")

当我在 localhost:4567 上运行这个应用程序时,CSS 加载得很好。但是,当我将它部署在我的 Web 服务器上时,CSS 不会加载。

在我的 Web 服务器上,使用以下命令访问该应用程序:rubyapps.mydomain.com/appname

如果我输入: rubyapps.mydomain.com/appname/css/bootstrap.css,我就能很好地看到我的 CSS 文件的内容。

完全困惑,不知道 Sinatra 如何处理这种情况,寻求一点帮助。

4

2 回答 2

1

您可能需要使用 Sinatra 的URL 助手

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).
于 2012-07-13T00:03:59.773 回答
0

也许这个?

%link(rel="stylesheet" href="../public/css/bootstrap.css")

或者...

%link(rel="stylesheet" href="/css/bootstrap.css")
于 2012-07-12T14:11:35.977 回答