【问题标题】:Send Page Requests Through Server?通过服务器发送页面请求?
【发布时间】:2010-10-31 18:20:29
【问题描述】:

如果用户单击 iframe 中显示外部站点的链接,是否可以通过 iframe 所在的服务器路由网页请求?

示例: somesite.com 上的 iframe 显示 google.com 用户单击指向 someothersite.com 的结果链接 该请求通过 somesite.com 的服务器发送并被记录下来,以便他们现在可以记录他们点击的链接。

可能吗?不是?

谢谢。

【问题讨论】:

    标签: php javascript html proxy


    【解决方案1】:

    不,浏览器的安全模型应该防止您篡改不同域上的网站(您必须这样做才能拦截点击)。

    您可以通过自己的服务器代理 iframe 并重新编写它...

    <iframe src="proxy.php?src=www.google.com"></iframe>
    

    proxy.php 的基本概念类似于(这不应该完成甚至工作 - 只是为了让您了解它应该如何工作):

    <?php
    
    // Get the contents
    $html = file_get_contents($_GET['src']);
    
    // Rewrite the links
    $html = preg_replace('/href=["\']?/i', 'href=clicky.php?src=', $html);
    
    // Output the HTML
    print($html);
    
    ?>
    

    【讨论】:

    • 我该怎么做呢?我用谷歌搜索了一下,但我得到的大多数结果都是使用外部代理来解释的,而不是你自己的服务器。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多