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.

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

报告相同问题?