使用 Morph Labs 的 Appspace 部署站点意味着无法自动将“myapp.com”重定向到“www.myapp.com”(并且无法访问 .htacess)。
是否有 rails 内方式来做到这一点?我需要像 subdomain-fu 这样的插件吗? ?
更具体地说,我正在尝试执行以下操作:
基本上,我总是希望在每个请求前都加上“www”子域(因为 SSL 证书的通用名称是“www.myapp.com”)。
最佳答案
也许这样的事情可以解决问题:
class ApplicationController < ActionController::Base
before_filter :check_uri
def check_uri
redirect_to request.protocol + "www." + request.host_with_port + request.request_uri if !/^www/.match(request.host)
end
end
关于ruby-on-rails - 在不使用 htaccess 的情况下将 'myapp.com' 重定向到 rails 中的 'www.myapp.com'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/327122/