2010-10-08 55 views
0

我写了一个简单的带有两个“路由”的Sinatra应用程序:“/ show”和“/ listshows”。当我在Webrick之上运行应用程序时,静态和非静态路由都可以很好地工作。下面是URL就是我使用:部署Sinatra应用程序后的路径问题

今天,我部署了我简单的应用程序在Apache的顶部和乘客2.我的Web服务器是我的私人网络上,并且是命名为Millhouse。我基本上要使用以下URL来访问应用程序:

的probem的是,“slwa”串是不是我的任何URL的一部分。例如,当您尝试访问“http:// millhouse/slwa”时,应该自动重定向到“http:// millhouse/slwa/listshows”。虽然我的应用程序确实重定向,但它最终会将我发送到“http:// millhouse/listshows”。 “slwa”部分丢失。

我不想创建一个新的虚拟主机,所以我在我的Ubuntu服务器上重新使用了“root”虚拟主机。这是我的虚拟主机:

<VirtualHost *:80> 
    ServerAdmin [email protected] 

    DocumentRoot /var/www 
    <Directory /> 
      Options FollowSymLinks 
      AllowOverride None 
    </Directory> 
    <Directory /var/www/> 
      Options Indexes FollowSymLinks MultiViews 
      AllowOverride None 
      Order allow,deny 
      allow from all 
    </Directory> 

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
    <Directory "/usr/lib/cgi-bin"> 
      AllowOverride None 
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
      Order allow,deny 
      Allow from all 
    </Directory> 
    ErrorLog /var/log/apache2/error.log 

    # Possible values include: debug, info, notice, warn, error, crit, 
    # alert, emerg. 
    LogLevel warn 

    CustomLog /var/log/apache2/access.log combined 

    Alias /doc/ "/usr/share/doc/" 
    <Directory "/usr/share/doc/"> 
     Options Indexes MultiViews FollowSymLinks 
     AllowOverride None 
     Order deny,allow 
     Deny from all 
     Allow from 127.0.0.0/255.0.0.0 ::1/128 
    </Directory> 

    ### Here's the only line that I added to the default 
    RackBaseURI /slwa 
</VirtualHost> 

我还创建了一个符号链接在/ var/WWW指向在公开目录为我的应用程序。最后,这里是我的config.ru:

# This is straight from the Phusion Passnger Users Guide" 
require 'rubygems' 
require 'sinatra' 

root_dir = File.dirname(__FILE__) 

set :environment, ENV['RACK_ENV'].to_sym 
set :root,  root_dir 
set :app_file, File.join(root_dir, 'slwa.rb') 
disable :run 

require 'slwa' 
run Sinatra::Application 

我缺少什么部分?

在此先感谢您的帮助!

汤姆金银丝

回答

1

你尝试过重定向URL(:控制器:动作)?

有同样的问题,即解决它,我......(除了CSS和JS公共资产...)

+0

我结束了使用EMK - 西纳特拉的URL换包装,使我的网址的工作。我甚至在我的博客上写过 - http://tompurl.com/2011/01/17/sinatra-lessons-learned/。无论如何感谢Udo! – 2011-03-17 20:04:15