473,899 Members | 4,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can you avoid that googlebot indexes PHPSESSID pages?

CAH
Hi

Can you avoid that googlebot indexes PHPSESSID pages? Googlebot is
indexing pages with PHPSESSID, which makes it think my page has a
infinite number of pages. How can one avoid this?

Here is an exsample of url that google register, that might make is
more clear what is happening

http://www.winches.dk/winches.php?ar...6f0d46334659ff...
http://www.winches.dk/winches.php?ar...b6aed41fc142ea...

I do use session registred ID, but if I visit my site I never see those
kind of urls? So how come google gets a hold of them?

Best regards
Mads

Apr 3 '06
29 4887
CAH wrote:
Hi

Can you avoid that googlebot indexes PHPSESSID pages? Googlebot is
indexing pages with PHPSESSID, which makes it think my page has a
infinite number of pages. How can one avoid this?

Here is an exsample of url that google register, that might make is
more clear what is happening

http://www.winches.dk/winches.php?ar...6f0d46334659ff...
http://www.winches.dk/winches.php?ar...b6aed41fc142ea...


Such a change in session id shouldn't happen in a normal site. Also,
AFAIK Google will remove the PHPSESSID from URL (after crawling(?)).

FWIW, <news:11******* *************** @g43g2000cwa.go oglegroups.com> (
http://groups.google.com/group/comp....7bb41576afe16d )

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Apr 4 '06 #11
CAH
> > http://www.winches.dk/winches.php?ar...6f0d46334659ff...
http://www.winches.dk/winches.php?ar...b6aed41fc142ea...
Such a change in session id shouldn't happen in a normal site.


Why not? I would think a session ID should be unique. If you think I am
doing something wrong, what could that be then?

Also, AFAIK Google will remove the PHPSESSID from URL (after crawling(?)).


you can try this seach in google site:www.winches.dk

or click her

http://www.google.com/search?q=site:...e=off&filter=0

Look at the last 100 entries or so.

Best regards
mads

Apr 4 '06 #12
CAH
> There was some discussion of forcing cookies, but the author didn't want
to limit his users, so...

How about doing something like this:

// See if the user agent is Googlebot
$isGoogle = stripos($_SERVE R['HTTP_USER_AGEN T'], 'Googlebot');

// If it is, use ini_set to only allow cookies for the session variable
if ($isGoogle !== false) {
ini_set('sessio n.use_only_cook ies', '1');
}


Hi Scott

The solution you have come up with, is the cool one. How can I test if
my host allows me to set ini_set('sessio n.use_only_cook ies', '1');
The way you suggest in your code? Can all do this on any host?
Any ideas as to how to chek to See if the user agent is Googlebot?

Thanks for the suggestions. I must say I have had my first encounter
with cookie problems, so I would like to get the PHPSESID back in the
url.

Best regards
Mads

Apr 6 '06 #13
CAH
> If this solutions works

User-agent: Googlebot
Disallow: /*PHPSESSID

it would be by far the simplest, I do however not feel to sure that it
does work, and have no opportunity to check it at this time.


PHPSESSID URLs restricted by robots.txt

In Google sitemap BETA I can see 10 URLs restricted by robots.txt , and
that is with the above robot text. So i guess that might do the trick,
what do you think is this and indication that the above robot text is
egnoug?
Cah

Apr 6 '06 #14
CAH wrote:
http://www.winches.dk/winches.php?ar...6f0d46334659ff...
http://www.winches.dk/winches.php?ar...b6aed41fc142ea...
Such a change in session id shouldn't happen in a normal site.


Why not? I would think a session ID should be unique. If you think I am
doing something wrong, what could that be then?


It shouldn't happen in a single session--session id remains same for
the single session unless:
1. Crawler is returning and caching in multiple run
2. You have used session_regener ate_id()
3. There are random absoulte links poining in from your site to your
site (instead of relative links)
Also,
AFAIK Google will remove the PHPSESSID from URL (after crawling(?)).


you can try this seach in google site:www.winches.dk

or click her

http://www.google.com/search?q=site:...e=off&filter=0

Look at the last 100 entries or so.


It doesn't seem to strip session id as I thought. If your site
contents doesn't rely on session (for non-members), you may safely turn
off trans sid
<news:11******* *************** @l41g2000cwc.go oglegroups.com> (
http://groups.google.com/group/comp....24f27f2b7ac610 )
--even you can selectively turn off only for the crawler by sniffing
user agent string and or IP.

But, if your site depends on session (for non-members and hence
crawler) and you'd like to enable session for crawler, but doesn't want
the trans sid, you need to go for some other hack. If that is your
situation, I may help you with the hack.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Apr 7 '06 #15
CAH

R. Rajesh Jeba Anbiah skrev:
CAH wrote:
> http://www.winches.dk/winches.php?ar...6f0d46334659ff...
> http://www.winches.dk/winches.php?ar...b6aed41fc142ea...

Such a change in session id shouldn't happen in a normal site.
Why not? I would think a session ID should be unique. If you think I am
doing something wrong, what could that be then?


It shouldn't happen in a single session--session id remains same for
the single session unless:
1. Crawler is returning and caching in multiple run


I would think this is what happens.
2. You have used session_regener ate_id()
3. There are random absoulte links poining in from your site to your
site (instead of relative links)
Also,
AFAIK Google will remove the PHPSESSID from URL (after crawling(?)).
you can try this seach in google site:www.winches.dk

or click her

http://www.google.com/search?q=site:...e=off&filter=0

Look at the last 100 entries or so.


It doesn't seem to strip session id as I thought. If your site
contents doesn't rely on session (for non-members), you may safely turn
off trans sid> <news:11******* *************** @l41g2000cwc.go oglegroups.com> (
http://groups.google.com/group/comp....24f27f2b7ac610 )
--even you can selectively turn off only for the crawler by sniffing
user agent string and or IP.

But, if your site depends on session (for non-members and hence
crawler)


it does denpend on sessions for non-members

and you'd like to enable session for crawler, but doesn't want the trans sid, you need to go for some other hack. If that is your
situation, I may help you with the hack.
Thanks, that is very kind of you. I think the robot text might be doing
the trick, and then no further tricks og hacks should be needed. But I
am following Google closely. Now, session.use_tra ns_sid, what does that
do, does it not turn of sessions I URL, and force cookies on the users?
I found this at another site

if(strpos($_SER VER['HTTP_USER_AGEN T'],"google")!==fa lse or
strpos($_SERVER['HTTP_USER_AGEN T'],"MSIECrawler") !==false)
{
ini_set("url_re writer.tags","" );
}

http://www.mtdev.com/2002/06/why-you...use_trans_sid/

But have not testet it.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/


Apr 7 '06 #16
CAH wrote:
R. Rajesh Jeba Anbiah skrev: <snip>
It doesn't seem to strip session id as I thought. If your site
contents doesn't rely on session (for non-members), you may safely turn
off trans sid> <news:11******* *************** @l41g2000cwc.go oglegroups.com> (
http://groups.google.com/group/comp....24f27f2b7ac610 )
--even you can selectively turn off only for the crawler by sniffing
user agent string and or IP.

But, if your site depends on session (for non-members and hence
crawler)


it does denpend on sessions for non-members


I doubt that. Anyway, it's better you check if it depends on
session again.
and you'd like to enable session for crawler, but doesn't want
the trans sid, you need to go for some other hack. If that is your
situation, I may help you with the hack.
<snip>
I found this at another site

if(strpos($_SER VER['HTTP_USER_AGEN T'],"google")!==fa lse or
strpos($_SERVER['HTTP_USER_AGEN T'],"MSIECrawler") !==false)
{
ini_set("url_re writer.tags","" );
}

http://www.mtdev.com/2002/06/why-you...use_trans_sid/


Actually you're turning off trans sid (see my link above) and there
by you're turning off the session for crawler. But, you said your site
needs session for crawler. And here goes my untested--to be improved--a
quick dirty hack:

<?php
/* Crawler SID removal hack: begin--------*/
/* Hack code should be placed on the top of every accessible script.
* or place it in a global common file say header.php or so.
* Important Assumption: Crawler indexes the final redirected URI */

/**
* Test if the request is from the crawler
*
* @return boolean
* @todo implement it or google for hundreds of codes
**/
function IsCrawler()
{
return true;
}

if (IsCrawler())
{
define('CRAWLER _SID_FILE', 'crawler_sid.tx t');

if (isset($_GET[session_name()])) // Is session id found in query
string?
{
$tmp_get = $_GET;
unset($tmp_get[session_name()]); //remove session id
// now rebuild query string...
$new_get = http_build_quer y($tmp_get);
$default_ports = array('https' => 443, 'http' => 80);
$prefix = (!empty($_SERVE R['HTTPS']) ? 'https' : 'http');
$current_url = $prefix .
(($_SERVER['SERVER_PORT'] != $default_ports[$prefix]) ?
':' . $_SERVER['SERVER_PORT'] : '') . '://'
. $_SERVER['HTTP_HOST']
. $_SERVER['PHP_SELF'];
// redirect to self, but with SID removed
header('Locatio n: '.$current_url . '?' . $new_get);
exit;
}
else // SID is not found (page got redirected); so we need to
set/load the crawler's session id
{
// the session id is been actually found in
CRAWLER_SID_FIL E for the crawler
if (($crawler_sid= @file_get_conte nts(CRAWLER_SID _FILE))!==false )
session_id($cra wler_sid);
}
}
/*----break: Crawler SID removal hack*/
// normal code...
session_start() ;
/* Crawler SID removal hack: continue ----*/
if (IsCrawler())
{
file_put_conten ts(CRAWLER_SID_ FILE, session_id()); //safely store
the crawler's session id in CRAWLER_SID_FIL E
}
/*----end: Crawler SID removal hack*/

// now, again normal code...
// ...
// testing a link...
echo '<p><a href="' . $_SERVER['PHP_SELF'] . '?a=100&b=50&c= 5">Test
link</a></p>';
$_SESSION['test'] = !isset($_SESSIO N['test']) ? 0 :
($_SESSION['test']+1);
echo '<p>'.$_SESSIO N['test'].'</p>';
?>
--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Apr 11 '06 #17
This is not the way to do it. This will prevent google from seeing any
page with a session id. Bad bad bad. You may as well just disallow
google altogether.

Apr 11 '06 #18
Ithink the best solutioin to this problem is to detect googlebot (+ any
other bots, yahoo slurp, msnbot..) and then set the session id to a
known value using session_id() that way you always have the session
when you expect it regardless of the current user-agent. Works a treat
for me.

Apr 11 '06 #19
fletch wrote:
Ithink the best solutioin to this problem is to detect googlebot (+ any
other bots, yahoo slurp, msnbot..) and then set the session id to a
known value using session_id() that way you always have the session
when you expect it regardless of the current user-agent. Works a treat
for me.


This is cool. I was thinking about similar hack after posting that
as previous did add SID to the links on the page (will be a problem if
users visit via cached pages).

So, I'm thinking of turning off trans sid for crawler and keeping
the session id in server and setting it via session_id()

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Apr 12 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7916
by: AmigaLemming | last post by:
As I understand my admins installed a PHP server and now my plain HTML pages also want to set a PHPSESSID cookie when loaded into a browser. Can I suppress this, e.g. by creating a configuration file like ..htaccess somewhere in my public_html directory? Is it possible to disable the setting of PHPSESSID cookies for plain HTML pages in general and maybe for PHP pages that don't need to track any session information?
4
8271
by: Arnaud | last post by:
Hi ! I would like to propagate data between php pages, in two cases : the pages are read by : 1- Internet Explorer It's ok, data are writen in one page, and read from another. I don't use PHPSESSID 2- from a mobile browser ( mobile i-Mode phone Nec22) After several tests, I understod it's impossible, because the session system tries to write a cookie on the browser...
7
7039
by: windandwaves | last post by:
Dear Gurus Is it correct that you do not have to pass the PHPSESSID in the header in order to keep a session going. What are the advantages/disadvantages of having the PHPSESSID in the header e..g. http://www.myurl.com/index.php?PHPSESSID=...... Thank you
24
2757
by: somaboy mx | last post by:
I've created a php page which is optimized for search engine indexation: no images, tables or css, just plain html with relevant meta tags etc. The page contains a list records pulled from a database, and for each record there is a link to the detail view for that record in this form: <a href="<?=$_SERVER ?>?rec=<?=$recordId ?>"> I've made sure the urlstring doesn't contain a variable called 'id' or something, since I heard some bots...
6
4590
by: Bonnie | last post by:
Hi: I'm hoping someone can shed some light on this issue. (I've been digging around everywhere and can't seem to find it by searching): I use the @import statement to attach an external style sheet on our site. I chose to use this technique rather than use the LINK tag because I wanted to hide the design from older browsers like NN4 and to present a clean, text-only version to JAWS and other accessibility screen readers.
3
2811
by: noop | last post by:
Hi, not really a html question, but... I've submitted my URL to Google for indexing. In the logs of my server, I see that googlebot has requested my /robots.txt and my /index.html, but it stopped there: there was no request for the other pages of my site. (It did so twice: after some time I re-submitted my URL, and googlebot still retrieved only the first page.) What did I do wrong? Here is a description of my site: - I didn't put any...
0
1766
by: John Smith | last post by:
Googlebot has been picking up numerous PHPSESSID name/value pairs in URIs at my website, and this causes duplicate hits and wasted bandwidth. I've since prevented PHPSESSID generation in my PHP script if Googlebot makes the request; like so: if(preg_match("/googlebot/i", $_SERVER) != 1) //session code here ....but this doesn't stop the PHPSESSID requests from Googlebot because they're already stored in its database, and it continues...
5
2922
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi everyone! I get some errors lately regarding: HTTP_USER_AGENT Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) and: System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
0
9845
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11276
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10866
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7204
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5891
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6082
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4721
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.