Forum Moderators: coopster

Message Too Old, No Replies

php headers and search engine

will the following code confuse or disgruntle the search engine spiders?

         

benlieb

6:12 pm on Nov 17, 2004 (gmt 0)

10+ Year Member



I use this to host more than my one domain allowance (see below). My question is do search engine spider/cralwers have problems with this or do they see the domains as "separate".

To make it more obvious, I resolve all my domain names to one ip address. From the index.php file that is default for that ip, I re-rout the client to a specific directory based on what domain name they entered to get there.

switch ($_SERVER['HTTP_HOST']) {
//----------------------------------------------------------------------------------------------------
case "www.somedomain.net" :
header("Location: ["...] . $_SERVER['HTTP_HOST'] . "/hf/pp/index.php");
break;

//----------------------------------------------------------------------------------------------------
case "www.anotherdomain.org":
header("Location: ["...] . $_SERVER['HTTP_HOST'] . "/hc/pp/index.php");
break;

//----------------------------------------------------------------------------------------------------
case "www.yetanother.net":
header("Location: ["...] . $_SERVER['HTTP_HOST'] . "/pe/pp/index.php");
break;

Salsa

11:28 pm on Nov 17, 2004 (gmt 0)

10+ Year Member



Benlieb, I'm no expert on this, but as no one else has yet answered you: yes, I'd expect some search engines will penalize that--probably for the redirect and perhaps for a number of other reasons, like how deep the files are in the tree. For a very powerful option, assuming you're running Apache, check out a site search [webmasterworld.com] for mod_rewrite. Add "headers" to the the search to maybe find a discussion closer to your needs.

Also, if you have access to your httpd.conf, couldn't you put those domains in VirtualHosts to give them their own roots?

mincklerstraat

2:00 pm on Nov 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



quite agree with salsa; you want to avoid redirects on your home page like the plague if search engine rankings are of concern.

Slade

5:06 pm on Nov 18, 2004 (gmt 0)

10+ Year Member



I am going to have to disagree here.

The redirect you're using does not appear to alter the domain name in any way, so it is OK. (feel free to disagree with cause)

The only thing I see happening here is a redeirect from http://www.somedomain.net/ to http://www.somedomain.net/hf/pp/index.php which is perfectly fine, no problem, what so ever.

Now, if you were typing in http://www.yetanother.net/ into your browser and being redirected to http://www.somedomain.net/pe/pp/index.php, that would be different. But as I can see it, you are not.

The secondary domains appear to be transparent to the user, with no trace of the other domains in the url or the redirect.

Congratulations, you're doing virtual hosting, probably in your virtual hosting account!

Slade

5:16 pm on Nov 18, 2004 (gmt 0)

10+ Year Member



you want to avoid redirects on your home page like the plague if search engine rankings are of concern.

There is nothing wrong with a redirect as long as you are sure which one you are using(301 vs 302) and know what it's affects are. header("Location: #*$!") sends 302 by default, and that's probably ok.

302 means yeah, the page you requested is valid, but get it's contents from here. 301 says the page you requested is officially now at a new location, so you should ask for it from there from now on. (paraphrased)

[w3.org...]
[php.net...]

Salsa

6:05 pm on Nov 18, 2004 (gmt 0)

10+ Year Member



Slade: No, in this case returning a 301 or 302 is not a good solution. They are alerts that you've done a redirect, so what you are suggesting is not transparent to crawlers, which is the issue.

Regarding my VirtualHost suggestion, you've again leapt to invalid conclusions. VirtualHosts are simply a way of hosting multiple domains on a server. They are especially useful when your servers have limited IPs because they allow multiple domains to use the same IP.

mincklerstraat

6:20 pm on Nov 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Slade - only cause I could cite is general SEO advice (must admit, dated, from quite a while back and I haven't seen it repeated lately, but I have the feeling fewer sites use redirects from the root page) and seeing sites a few years back gain in page rank when the redirect was removed and they were restored to the webroot - and SE's have certainly changed since then. I don't know if these scripts sent out any headers other than 'Location:' alone. At that time, "the word on the street" was that 301 Moved Permanently was the best way of maintaining pagerank for moved pages.

The w3c is clear about what 'should' be the case, and 301 and 302 redirects are transparent to the user except for the change in the browser address bar; but of course, SE's do not necessarily follow the w3c's recommendations when it comes to browser behavior - in general I wouldn't worry too much about a 301 redirect, since they are known to 'move' pagerank and other page information along to the new page - but your front page is usually mission critical in terms of distributing page rank. Slade, have you seen instances of redirects from the home page which maintained PR / positions compared to just having home page in webroot? You obviously have different info from mine, maybe more up-to-date. Must admit, I'm still with Salsa here. (actually, posting this question in 'search engine promotion' or one of the SE forums might get you a better answer). I'd also use the mod_rewrite approach like he suggests if I had to try something like this.

Slade

10:49 pm on Nov 18, 2004 (gmt 0)

10+ Year Member



Original Poster: My question is do search engine spider/cralwers have problems with this

No, they will not have issues with your redirects, see links below:

[webmasterworld.com...]
[webmasterworld.com...]
[webmasterworld.com...]
[webmasterworld.com...]

or do they see the domains as "separate".

Yes, they will see the domains as seperate, as long as there will never be a redirect that crosses domain names.

Those, were the questions...

Salsa:No, in this case returning a 301 or 302 is not a good solution. They are alerts that you've done a redirect, so what you are suggesting is not transparent to crawlers, which is the issue.

I'm not quite sure why you're afraid of 30x redirects. The redirect will be entirely within the domain the request appears in, which is ok, see my links above.

Regarding my VirtualHost suggestion, you've again leapt to invalid conclusions. VirtualHosts are simply a way of hosting multiple domains on a server. They are especially useful when your servers have limited IPs because they allow multiple domains to use the same IP.

I did not even see your comment on virtualhost's at the time. I was referring to using the HTTP_HOST variable to determine which site's content to display, which is essentially what virtualhost'ing is.

mincklerstraat: you want to avoid redirects on your home page like the plague if search engine rankings are of concern.

[webmasterworld.com...]

Again, I don't know why yall are so afraid of redirects. I have seen some things in the last few months with 302's and links from other site's, but that's not what we're talking about, and actually would work just fine for the situation he's describing.

If you want to provide the same function without using the redirects, you can test for the host name in .htaccess and redirect it in there.

[edited by: coopster at 2:05 am (utc) on Nov. 19, 2004]
[edit reason] fixed quote tag [/edit]

mincklerstraat

8:40 am on Nov 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Slade: btw, really liked your answer here [webmasterworld.com]. Hutcheson agrees with you in the thread you cite, or at least with the practice of redirecting from one page in the root directory to another in the root directory. He also brings up the relevant point that all non-slashed directory requests are given redirects to the slashed variant - Apache uses 301, IIS previously used 302 I believe, II6 I think uses 301 (not quite sure, not a ms guy).

I'd still be very reluctant about home page redirects - often 'old' SEO advice doesn't get irrelevant, it's just not discussed anymore since it's assumed 'everybody knows already'. Before I'd employ home-page redirects, I'd also want to see people I knew better on the SEO forum state that this is no longer a problem - what has changed from the situation previously, or some statistics from a recent case. Even 'senior members' are fallible. Unfortunately, searching the site for 'homepage' and 'redirect' brings up so much stuff it's hard to find recent threads on the matter. I know my hits went way up when I got rid of my redirect - problem is, that was 2 years ago. I still, though, couldn't point a single well-ranking site that uses a redirect at the home page level - you might be able to provide me with one.

Redirects are still 'exception handling' behavior, no matter how useful and frequently used. SE's change their algos, everybody goes nuts trying to find out what the new 'rules of ranking' are. It's entirely possible that a SE that today shifts the pagerank from example.com (heavy in pagerank; all links point to this page) to example.com/this/page.htm because of a properly-done redirect, tomorrow will have some other algo handling redirects in general (since redirects are so commonly used by spammers, this is quite likely actually).

Like you suggest, though, the mod_rewrite option would be transparent to search engines as well, and in my opinion a better way to be sure about things.

And another note to benlieb: however you go about this, make sure that a spider in domaina.com can't accidently spider the pages which are supposed to be in domainb.com - you could check this with the $_SERVER['HOST'], perhaps.

benlieb

8:22 am on Nov 21, 2004 (gmt 0)

10+ Year Member



mincklerstraat: How do I make sure of this? Do you mean not to have any links in domainA.com point to domainB.com? Because there are currently some links between the "sites" but not relative ones.

mincklerstraat

8:30 am on Nov 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



benlieb: regarding last note- ignore that one, I see now tha that if you use mod_rewrite for this, the rules will be pretty waterproof and you won't have a problem of someone being in a directory that's 'theoretically' part of one domain but actually in the other domain. When I first used mod_rewrite I had problems but in a different situation, and I don't think you could get such problems with a setup like this.