如果您已登录,此 URL:https://download.ama-assn.org/resources/doc/usan/x-pub/usan-february-2014-newsletter.pdf返回 html 页面:
<div id="dlblock">
<a href="http://www.ama-assn.org">
<img src="https://www.ama-assn.org/resources/images/header/ama-logo.png" border="0">
</a><br><br>
You are about to download<br>
<strong>
<a id="file-link" href="/resources/doc/usan/x-pub/usan-february-2014-newsletter.pdf" target="_blank">usan-february-2014-newsletter.pdf</a>
</strong>
If you are not automatically redirected, please
<a href="/resources/doc/usan/x-pub/usan-february-2014-newsletter.pdf" target="_blank">click here</a>
to begin your download. <br><br>
<small>Copyright 1995-2014
<a href="http://www.ama-assn.org">American Medical Association</a> All rights reserved.
</small>
如果您点击此页面上的链接(并且该网址与刚刚在新窗口中打开的页面相同),您将获得 pdf 文件。
我不明白服务器如何决定何时提供 html 以及何时提供 pdf - 这是如何实现的?
最佳答案
服务器可能会读取 httpreferer
请求 header ,如果它与页面的 URL 匹配,则提供 PDF 版本。
关于javascript - 相同的 URL 提供不同的内容 - 为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22922195/