【发布时间】:2018-01-14 10:53:08
【问题描述】:
我关注了this tutorial,以便将托管在子域 (blog.botletter.com) 上的博客重定向到我的 Heroku rails 应用程序目录 (https://www.botletter.com/blog/)。
重定向适用于博客主页 (/blog/),但不适用于文章 URL。
我猜这是 Rails 应用程序中的配置问题,但我找不到错误。这是 Heroku 中的日志:
at=info method=GET path="/blog/invite-team-members/" 主机=www.botletter.com request_id=23b81c9a-e20b-4261-aea4-87adfb781554 fwd="195.154.32.17" dyno=web.1 连接=0ms 服务=412ms 状态=500 字节=725 协议=https
这是我的 config.ru 文件(我没有像教程中那样使用用户名和密码,因为博客没有使用任何访问限制):
require_relative 'config/environment'
use Rack::ReverseProxy do
reverse_proxy /^\/blog(\/.*)$/, 'https://blog.botletter.com$1', :timeout => 500, :preserve_host => true
end
run Rails.application
我的路线:
get '/blog' => redirect("https://www.botletter.com/blog/")
get '(*path)', to: 'application#blog', constraints: { subdomain: 'blog' }
我在应用程序控制器中的“博客”操作:
def blog
redirect_to "https://www.botletter.com/blog#{request.fullpath.gsub('/blog','')}", :status => :moved_permanently
end
感谢您的帮助!
【问题讨论】:
标签: ruby-on-rails wordpress heroku