在Sinatra中,如何從特定頁面重定向網頁?如何從Sinatra的特定頁面重定向網頁?
require 'sinatra'
get "/A" do
redirect '/B'
end
get "/B" do
# if comes from A
# "IT COMES FROM A"
# else not from A
# "NOT FROM A , REDIRECT TO C"
# redirect '/C'
# end
end
我想學習如何做到這一點?
我可以使用JavaScript或HTML來做我想做的事嗎?
或者,它必須在Sinatra完成?
我想這一點,但它一直空,
get "/B" do
mypath = URI(request.referer || '').path
if mypath == '/A'
"hi i am b , u come from a"
else
"--#{request.referrer}--"
redirect '/C'
end
end
感謝您的編輯!下次我會注意到。 – 2014-09-24 12:07:31