2017-04-07 16 views
-2

我需要排除任何關於它的錯誤,所以我在這裏問。我已經被一個客戶要求,以創建可以通過在自己的網站的鏈接訪問一個頁面,但不能被訪問(或至少將被重定向到另一個地方)通過複製鏈接或將其輸入到瀏覽器中手動地址欄。如果在瀏覽器中手動輸入的話,是否可以通過網站創建鏈接,但鏈接不起作用(以同樣的方式)?

是來記我用的是網站上的cookie,然後檢查關鍵頁面打開,當用戶瀏覽器存儲這個cookie的唯一的事情。因此,不是來自基本網站的另一個用戶將看到不同的東西或者通過javascript等重定向(例如使用cookie作爲if {…)。

讓我知道如果我監督的可能性,或者是乾脆:「有沒有辦法做到這一點。」謝謝!

編輯

@marmeladze:對不起我不熟悉需要技巧。所以我不能採取這種我害怕的方式。而且我無法說出它是否有效=正確的答案。

@mplungjan:哇!不知道這個看似很簡單的推薦人的事!我認爲這是在接受的答案這裏去的方式:Checking the referrer 酷!可悲的是,我的鏈接雖然是PDF的直接下載鏈接,所以這兩種解決方案都不會起作用,因爲我可能(我錯了也許?)將無法將代碼放入其中。

+1

有一種方法我相信。讓我創建一個模式併發布它。 – marmeladze

+1

對於_Questions,您可能會被拒絕,因爲它們傾向於吸引自以爲是的答案和垃圾郵件,因此要求我們推薦或查找針對Stack Overflow的書籍,工具,軟件庫,教程或其他非本地資源。相反,請描述問題以及到目前爲止解決問題所做的工作。 1_ - 你的cookie想法或測試引用是一種方法。 – mplungjan

+0

請閱讀[在什麼情況下我可以添加「緊急」或其他類似的短語到我的問題,以獲得更快的答案?](https://meta.stackoverflow.com/q/326569) - 摘要是,這不是解決志願者問題的理想方式,而且可能對獲得答案起反作用。請不要將這添加到您的問題。 – halfer

回答

1

的解決方案的嘗試與sinatra

require "sinatra" 

get '/posts/:slug' do 
    "This is a post about #{params[:slug]}" 
end 

get '/*' do 
    "This is an all-rounder.\n Params: #{params[:splat]}" 
end 

在sinatra中,最高的路線優先於休息。所以,如果你的網址是。如yoururl/posts/post-name,它將被第一條路線捕獲,並將呈現文本「這是關於後名的帖子」。所有其他人將被其他路線抓住。

$ curl localhost:4567; echo 
This is an all-rounder. 
Params: [""] 
$ curl localhost:4567/posts/on-old-sage; echo 
This is a post about on-old-sage 
$ curl localhost:4567/posts/information-retrieval; echo 
This is a post about information-retrieval 
$ curl localhost:4567/posts/unbearable-lightness-of-being; echo 
This is a post about unbearable-lightness-of-being 
$ curl localhost:4567/make/it/as/deep/as/you/can; echo 
This is an all-rounder. 
Params: ["make/it/as/deep/as/you/can"] 
$ curl localhost:4567/who/is/afraid/of-hegel; echo 
This is an all-rounder. 
Params: ["who/is/afraid/of-hegel"] 
$ curl localhost:4567/all/socrates/knows/is/he-knows-so-little-about-things; echo 
This is an all-rounder. 
Params: ["all/socrates/knows/is/he-knows-so-little-about-things"] 
相關問題