簡體   English   中英

如何將force_ssl與302一起使用

[英]How to use force_ssl with a 302

如果我把它放在config / environments / production.rb中,我的網站將使用301重定向(永久)成為所有SSL。

config.force_ssl = true

如何使用302重定向(臨時)執行此操作?

RubyOnRails.org說使用:status,但我仍然不確定如何在production.rb文件中執行此操作。 (這是Heroku上的Rails 3.2.13。)

謝謝。

你可以將它放入你的主控制器

class SessionController < ApplicationController
  force_ssl_redirect({:status => :found})

def new
    # Non-SSL access will be redirected to SSL
  end
end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM