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

upload.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 ファイルの内容を正しく表示できます。

完全に混乱しており、シナトラがこの状況をどのように処理するかを理解できず、少し助けを求めています。

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 に答える