dpwuvfpu52502 2012-05-02 18:21
浏览 144
已采纳

在PHP中获取顶级框架(浏览器中的地址栏)URL?

I'm sorry for my English, it isn't so good... I need help with a simple PHP program: if the page's URL contain a specific word, the content is showed. If there isn't it, the entire page redirects. I would use this to prevent me from frames that other webmasters make to "steal" my website contents. For this is ok.. But a friend of mine need to make a black list of specific words, not a white list. So if the URL contain a word, the entire page redirects. I tried using *$_SERVER['HTTP_REFERER']* but if the "thief" put the frame on an external website that is not in the black list and after he make a frame of the frame, the content is showed and the page doesn't redirect.. So I think it's like that: *$_SERVER['HTTP_REFERER']* could read just 1st level frame and not the main page (top frame). I really need help with this, I can't make it with Javascript because we want to keep the code not visible.

If it is not possible, is there a method to pass a JS variable value to a PHP variable for my case?

Thank you in advance!

  • 写回答

1条回答 默认 最新

  • douzhong1907 2012-05-02 18:31
    关注

    This is only possible by javascript if and only if the top level domain is the same as yours. If that is the case, you could make an ajax call to the server, passing along the url and then the server could determine whether or not to redirect.

    Instead of showing what the code would look like, I'm much more inclined to persuade you against this approach. If you have content that you don't want people to steal, you should make your site non-public (i.e. users must login). If that is not possible, the content that you are worried about sounds like it shouldn't be on the internet.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度