Skip to content
WJunction - Webmaster Forum

Please help me with a little fix

Status
Not open for further replies.

Divvy

Experienced Member
806
2009
18
Hi friends,

Can someone please help me?

I use this method to cloak my affiliate links:
https://yoast.com/cloak-affiliate-links/

So in our list we just need to put the links like this:
Code:
name,http://domain.com/?p=2

And we will use the following link:
Code:
http://www.mydomain.com/out/name

My main problem is with the comma... he detects the link after the first comma, but lets imagine that the link is something like:
Code:
http://www.affiliatedomain.com/track/gTk2NzMwdjQ6sTc,24/

So the problem is that he cant read all url, because the url have an comma too, so the script will read only:
Code:
http://www.affiliatedomain.com/track/gTk2NzMwdjQ6sTc

And will ignore the ,24 part.

Is there any fix to this please? A way that the script only read the first comma and ignore the others from urls?

Here is the code source:
https://gist.github.com/jdevalk/5622742

Help :)
 

6 comments

you can try escaping the , like
Code:
http://www.affiliatedomain.com/track/gTk2NzMwdjQ6sTc\,24/

or enclose your settings with .e.g '
then you have to change the following line:

Code:
while( $data = fgetcsv( $f ) ) {
to
Code:
while( $data = fgetcsv( $f, ",","'" ) ) {
then your file should look s.th. like this:
Code:
'default','http://example.com'


Though i haven't tested it live. so i don't know if this will work
 
Last edited:
I mate, thank you very much for your reply and your help! :)

I didnt tested your code yet because I have found a way to fix the comma issue in the original code.

Using:
Code:
test, "http://yoast.com/?p=2"


Instead:
Code:
test,http://yoast.com/?p=2


What method do you think is better? Your code or using original code and enclosing the link in quote marks?


Thanks buddy! :)
 
The " are the standard-value the fgetcsv will use.
So it's essentially the same as my second idea :)

So using that will work fine, of course ^^
 
Thank you my friend :-)

I think that I'm going to use the original code since I don't need to do any change.
Sorry for the work that you had, but I really appreciate for trying to help me :-)

__________________
Added after 1 Day 6 Hours:

Btw, in my website I have some urls with nofollow tag, but I want to remove all nofollow tags and also starting to use this cloak script in all my links.

But I notice this in the official page:
https://yoast.com/cloak-affiliate-links/

It says:
"Affiliate links are ads, and those should be nofollowed or otherwise prevented from leaking PageRank to the advertiser. Instead of nofollowing each and every link, which is painful and you’re bound to forget at some point, why not make sure search engines can’t follow the link at all?"

And If you check the source code:
https://gist.github.com/jdevalk/5622742

You will see that line:
header( "X-Robots-Tag: noindex, nofollow", true );

So probably this cloak script is not doing what I want right? Making everything dofollow.
I can be wrong, but I think that using this script is the same If I'm adding nofollow tag manually in each link affiliate link right?

If this is true, maybe is better to remove , nofollow from the code right? Or should I remove noindex too!?
Whats the better solution?

Thank you buddy!
 
Last edited:
Hi,
so your script does the following.

Google will spider your affilate-link. (http://www.mydomain.com/out/name)
then google will geht the header-setting of nofollow and noindex, so the spider should stop there and not going any further, leaking pagerank etc.
nofollow wil say the (google)bot, that it shouldn't go any further
and
noindex will prevent the google-bot from indexing your outging links.

so a site with youdomain.com/out/*** should not appear in any google results.

So,
if you want to have the google bot following and indexing this link, you have to remove the header-line from the script.
That's all there is to do, do let google follow the links :)

For SEO-Optimazation i would say, it's okay to let google follow, but not index the site - since there won't be any other content, than the rewrite header.
Thus i would suggest to only remove nofollow
 
Thank you my friend, that was exactly what I thought :)

Thank you once again for the explanation.
 
Status
Not open for further replies.

About the author

D
Experienced Member · Joined
806
Messages
18
Reactions
18
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom