第一次在这里发帖。
我遇到了最奇怪的问题,老实说我以前从未见过这个问题。我有一个内部URL转发服务,我的客户可以在其中创建关键字并将该关键字重定向到他们指定的目标。这一直很有效,但今天我被告知重定向到PDF的问题。
我的一位用户创建了一个PDF的短网址,并抱怨点击统计信息已经过时了。当我研究这个问题时,我注意到很多客户尝试了我称之为重定向循环的东西。
基本上,他们不断地使用不同的字节范围一遍又一遍地请求短URL。这种情况不断发生;有时我连续看到60 + 70。我已经尝试过更改缓存标头等等,但我做的任何事情似乎都无法解决这个问题。甚至尝试将302更改为301.没有运气。 :(非常感谢任何反馈。谢谢你们!
这是我通过tcpdump捕获的片段:
GET /ShowcaseGuide HTTP/1.1
Accept: */*
Referer: wwww.someinternalserver.com
Accept-Language: en-US
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Accept-Encoding: gzip, deflate
Host: goto.mydomain.org
DNT: 1
Connection: Keep-Alive
Cookie: s_pers=xxxxxx
HTTP/1.1 302 Found
Date: Tue, 19 Nov 2013 20:09:52 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.3.3
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: private, must-revalidate
Pragma: no-cache
Location: http://internalserver.mydomain.org/links/Get_the_Most_Out_of_the_Showcase.pdf
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 20
Keep-Alive: timeout=5, max=200
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
GET /ShowcaseGuide HTTP/1.1
Accept: */*
Range: bytes=2178560-2179071, 2179072-2179369
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Host: goto.mydomain.org
DNT: 1
Connection: Keep-Alive
Cookie: s_pers=xxxxxx
HTTP/1.1 302 Found
Date: Tue, 19 Nov 2013 20:09:56 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.3.3
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: private, must-revalidate
Pragma: no-cache
Location: http://internalserver.mydomain.org/links/Get_the_Most_Out_of_the_Showcase.pdf
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 20
Keep-Alive: timeout=5, max=199
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
GET /ShowcaseGuide HTTP/1.1
Accept: */*
Range: bytes=1867776-1884159
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Host: goto.mydomain.org
DNT: 1
Connection: Keep-Alive
Cookie: s_pers=xxxxxx
HTTP/1.1 302 Found
Date: Tue, 19 Nov 2013 20:09:57 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.3.3
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: private, must-revalidate
Pragma: no-cache
Location: http://internalserver.mydomain.org/links/Get_the_Most_Out_of_the_Showcase.pdf
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 20
Keep-Alive: timeout=5, max=198
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
答案 0 :(得分:0)
也许做这样的事情而不是使用重定向?应该在浏览器中显示
/ShowcaseGuide/index.php:
<?php
header('Content-type: application/octet-stream');
header('Content-Disposition: inline; filename="Get_the_Most_Out_of_the_Showcase.pdf"');
readfile('../links/Get_the_Most_Out_of_the_Showcase.pdf');
?>
可能是浏览器开始下载PDF,然后转到初始页面(/ShowcaseGuide/index.php),然后再次重定向到同一个文件。如果它正在发生,它可能依赖于浏览器。
如果您要将第二行header
行下载而不是在浏览器中查看,请将其更改为header('Content-Disposition: attachment; filename="Get_the_Most_Out_of_the_Showcase.pdf"');
。