开发者

How does Google know server side code?

Maybe I'm a little behind the eight ball. Hopefully someone can explain this. I had a webpage that I didn't want displayed to the public, for my eyes only (temporarily). It wasn't confidential or that important so I p开发者_如何学编程ut a simple "if variable is not set, redirect". Thinking nothing could figure out the variable, it would be okay temporarily.

Google figured it out though!

I'll give example code.

<?php

    if(!isset($_GET['debug'])){
         header("Location : http://www.example.com");
    }
?>

Google knew that to view the rest of the page, it needed to have the "debug" GET parameter in the URL.

How did it figure this out?


You didn't exit() after setting the redirect header(), so the rest of the page was generated and returned to the client, anyway.


Did you actually test your code?

Either you have a bug, or somebody put a link to your page with the "debug" parameter set. (Or submitted the URL to Google directly.)

I actually had something similar happen to me; I set up a "private" Web page, sent the URL to a few friends, and asked them not to share it with anybody. One of my friends is the kind of person who will reliably do the opposite of what I ask, so he submitted it to Google...

Anyway, no, Google cannot read your server-side source code.


You could temporarily send a noindex header for your page, and when you're done testing, remove it, so that Google doesn't index your page.

Of course, dossy is correct—you didn't run exit() after header(), so the rest of your page is still returned.


if(!isset($_GET['debug'])){
     header("Location : http://www.example.com");
}
else 

{ //redirect to the normal user page which is designed for all the user } ?>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜