【发布时间】:2012-02-06 19:33:26
【问题描述】:
如何让http://domain.com 301 重定向到http://www.domain.com?我习惯使用 .htaccess 来 ModRewrite 它,但我知道我不能在 Heroku 上这样做。
.htaccess 示例:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
我的文件结构:
- /public
--- /style
--- index.html
- config.ru
我只是提供单个页面,我的 config.ru 包含以下内容:
use Rack::Static,
:urls => ["/style"],
:root => "public"
run lambda { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
}
【问题讨论】:
-
这里没有一个答案对我有用,我很久以前就放弃了。
-
我也有同样的问题……还是没有解决办法?
标签: ruby-on-rails ruby redirect heroku rack