php Redirects, noindexing & best practices.

efeezy

New member
Oct 5, 2007
5,250
136
0
50
Sorry if this is a relatively basic question. I'm hoping someone can school me a little more on redirection best practices.

I've setup a handful of pages with php redirects like such ;

<?php
header( 'Location: http://www.myaffiliatelink.com/sdfds4324dfdfgdfgdL?sid=' ) ;
?>

They're all in a "resources" directory on my server. My main reason for this was just to have the links look pretty on my site. So I don't have that clunky affiliate link showing in the status bar. I'm not looking to cloak/mask any referrers or do anything shady, I just want to make the link look nice.

That said, I don't want Google indexing all of these redirect pages I've set up in this Resources folder.

So my question is, should I just disallow /resources in robots.txt?
Or should I add a noindex tag to each of these redirect pages.
Or is there a better way to be doing this entire thing and are these redirect methods frowned upon by Google?

Thanks for any tips.
 


Thanks man. I was hoping that would be the easiest way to get it done.
 
Any idea what Google's position is on having several of these types of redirects on a product page? Would they look at it as cloaking or masking even though it's basically the same idea as a URL shortener?
 
i think they would look at it as cloaking still.

last time i heard people were using
header('HTTP/1.1 301 Moved Permanently');

before their header(location:) line to make it more acceptable by google. but this strategy might be outdated by now
 
Or is there a better way to be doing this entire thing and are these redirect methods frowned upon by Google?

Depends on your setup, but I would imagine mod_rewrite is a better way to go than outputting "Location: " headers everywhere.
 
Depends on your setup, but I would imagine mod_rewrite is a better way to go than outputting "Location: " headers everywhere.

In that case, say I've got 10-15 different affiliate URL's I'm using across my site, what's the easiest way to set up a Google friendly mod_rewrite redirect in .htaccess so I can have a "pretty" url for each of those URL's?
 
In that case, say I've got 10-15 different affiliate URL's I'm using across my site, what's the easiest way to set up a Google friendly mod_rewrite redirect in .htaccess so I can have a "pretty" url for each of those URL's?

htaccess - short and friendly URL for affiliate links - Webmasters Stack Exchange

Functionally, there really isn't much of a difference here compared to the 301 in the php file. It's just that htaccess handles it at the bare metal server level without the need for actually executing a php script (which will happen so fast there's no difference perceptible anyways)
 
Give me a couple example URLs (URL you use, and URL it links to), and I'll give you the redirect rules for them. Oh, and you running Apache or Nginx?
 
htaccess - short and friendly URL for affiliate links - Webmasters Stack Exchange

Functionally, there really isn't much of a difference here compared to the 301 in the php file. It's just that htaccess handles it at the bare metal server level without the need for actually executing a php script (which will happen so fast there's no difference perceptible anyways)

See, now this is the type of thing that irks me. You guys constantly preach about how efficient and up-to-date you are, while harping on me about being inefficient and not knowledgeable.

Then you turn around, and provide advice that throwing a bunch of "header('Location: ...');" tags in dozens of files is just as good as mod_rewrite.

You gotta be kidding me...
 
See, now this is the type of thing that irks me. You guys constantly preach about how efficient and up-to-date you are, while harping on me about being inefficient and not knowledgeable.

Then you turn around, and provide advice that throwing a bunch of "header('Location: ...');" tags in dozens of files is just as good as mod_rewrite.

You gotta be kidding me...

To be fair, I was answering his question, not providing the method I would use. I would have this handled at the CMS level, where you can just add/remove links at will using a plugin like 301 Redirects for Wordpress.
 
I appreciate both your solutions. I guess I should have stated that all I really want is an easy method to set up this type of redirect that will not look like cloaking or masking or any other shady method that Google will whack me for doing. Whether it's .htaccess or a WP plugin, I'm fine with the easiest one that keeps my site on the up & up.
 
I appreciate both your solutions. I guess I should have stated that all I really want is an easy method to set up this type of redirect that will not look like cloaking or masking or any other shady method that Google will whack me for doing. Whether it's .htaccess or a WP plugin, I'm fine with the easiest one that keeps my site on the up & up.

Well by definition, this is link masking, so there's not much you can really do about that. I suppose you could link to another domain that you control that then does the link masking so as to make it look like it's them, not you...but that still isn't really a solution around link masking.
 
Gotcha. From what I can find regarding this from a Google standpoint, as long as it's not being done to intentionally fool or mislead a visitor, pass pagerank, or confuse Google's crawlers, then it's ok. I guess the definition of those things are debatable.
 
Gotcha. From what I can find regarding this from a Google standpoint, as long as it's not being done to intentionally fool or mislead a visitor, pass pagerank, or confuse Google's crawlers, then it's ok. I guess the definition of those things are debatable.

Besides some type of onclick javascrfipt sort of linking, I am confused as to what could fool Google on this. If we are rewriting or redirecting, the destination is the same. Does Google not follow links? That is hard for me to believe.

Or what am I missing?
 
Besides some type of onclick javascrfipt sort of linking, I am confused as to what could fool Google on this. If we are rewriting or redirecting, the destination is the same. Does Google not follow links? That is hard for me to believe.

Or what am I missing?

Because as a user of the website, you might hover over a link and see "http://www.domain.com/a-product-name" and then when you click it, it redirects you off site. The user would have no way of knowing that redirect exists until they click. So what the user sees/expected and what they got are not consistent and voila, you're a cloaker/masker.
 
Snooping around I found this, but haven't tried it. Might be worth a shot. Along the same lines of what laner mentioned above.

Code:
header('HTTP/1.1 301 Moved Permanently');
header('Location: '.$url);// perform calculations here,
// i.e.
// open database connection
// lookup of $url entry
// if it exists add 1 to its count
// if it does NOT exist create entry and add 1 to it's count
// close database
exit;
?>

Google Friendly Redirect, Php Script - icanbeCreative
 
Because as a user of the website, you might hover over a link and see "http://www.domain.com/a-product-name" and then when you click it, it redirects you off site. The user would have no way of knowing that redirect exists until they click. So what the user sees/expected and what they got are not consistent and voila, you're a cloaker/masker.

Makes sence and I am sure the omnipotent Gbot can easily understand my intentions.

Snooping around I found this, but haven't tried it. Might be worth a shot. Along the same lines of what laner mentioned above.

Code:
header('HTTP/1.1 301 Moved Permanently');
header('Location: '.$url);// perform calculations here,
// i.e.
// open database connection
// lookup of $url entry
// if it exists add 1 to its count
// if it does NOT exist create entry and add 1 to it's count
// close database
exit;
?>

Google Friendly Redirect, Php Script - icanbeCreative

Interesting link.
efeezy, you are hand coding? Because of course as mentioned there are plugins that have invented this wheel.
 
The only reason I'm I'm looking for a hand coded solution is to avoid having another plugin sucking up resources. The lighter my WP site the happier I am, and if there's a simple hard coded method, I'll take it over a plug in any day.