简体   繁体   English

获取网址内容忽略重定向与PHP卷曲

[英]get content of url ignoring redirect with php curl

Is possible ignore a 301 Moved Permanently redirect and get contents of original webpage. 可以忽略301 Moved Permanently重定向并获取原始网页的内容。 Example: I have a domain1.xxx/post1/ and this redirect to domain2.xxx/home/ (but i'm sure that post1 is still prensent in first url) is possible get content of post1 from the domain1.xxx? 示例:我有一个domain1.xxx/post1/,这个重定向到domain2.xxx/home/(但我确定post1仍然在第一个url中存在)可能从domain1.xxx获取post1的内容?

<?php 

$url = 'domain1.xxx/post1/'; 
    $ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,$url); 
curl_setopt($ch, CURLOPT_HEADER,1); 
curl_setopt($ch, CURLOPT_NOBODY,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //important
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);//important

$r = curl_exec($ch); 
curl_close($ch); 
echo $r;

?>`

But so return me : 但是回复我:

"Moved Permanently “永久移动

The document has moved here." 该文件已移至此处。“

is a test is not hacking i have a authorization of owner of the site to test this. 是测试不是黑客我有网站所有者的授权来测试这个。 The site is done with wordpress. 该网站使用wordpress完成。

Thnak you 骗过你

It's entirely unlikely for this to be possible given that it's usually the web server which serves the 301 information and redirects the page (eg a .htaccess file). 鉴于它通常是提供301信息并重定向页面的Web服务器(例如.htaccess文件),因此完全不可能实现这一点。 This means the web server won't look for a web page to serve and thus won't serve up files or data. 这意味着Web服务器不会查找要提供的网页,因此不会提供文件或数据。

In fact, it's likely that the original content doesn't even exist any more, if the owner has already deleted the content (or moved it to the new place). 事实上,如果所有者已经删除了内容(或将其移动到新位置),原始内容可能不再存在。

(I use the word "likely" in this as it really depends on specific server configuration.) (我在其中使用“可能”一词,因为它实际上取决于特定的服务器配置。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM