如果在浏览器中手动输入,是否可以从不起作用的网站创建链接(以相同方式)?

时间:2017-04-07 08:08:43

标签: javascript html cookies hyperlink

我需要排除有关它的任何错误,所以我在这里问。我被客户要求创建一个页面,可以通过他的网站上的链接访问但无法访问(或至少会被重定向到另一个地方)手动通过复制链接或将其输入浏览器地址栏。

我唯一想到的是在网站上使用cookie,然后在关键页面打开时检查用户浏览器是否存储了此cookie。因此,不是来自基础网站的其他用户将看到不同的内容或通过javascript等重定向(例如,使用cookie if {…)。

如果我监督了一种可能性,或者只是简单地说:“没有办法做到这一点,请告诉我。”谢谢!

修改

@marmeladze:抱歉,我不熟悉要求技巧。所以我不敢这样害怕。我无法说它是否有效=正确答案。

@mplungjan:哇!不知道这个看似非常简单的推荐人的事情!我认为这是接受答案的方式:Checking the referrer 凉!可悲的是,我的链接虽然是PDF的直接下载链接,所以这两种解决方案都不会起作用,因为我可能(我错了?)将无法将代码放入其中。

1 个答案:

答案 0 :(得分: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"]