Freelancer.com

Go Back   Warrior Forum - The #1 Internet Marketing Forum & Marketplace > Warrior Support Forums > Programming
Register Blogs Social Groups CalendarHelp Desk

Reply
LinkBack Thread Tools
Unread 29th December 2008, 03:36 PM   #1
Senior Warrior Member
War Room Member
 
Join Date: 2007
Location: , , .
Posts: 2,533
Thanks: 118
Thanked 65 Times in 59 Posts
Default How To Do PHP Redirect In Wordpress?

Hi,

im trying to cloak a clickbank affiliate link with a PHP redirect as I heard this is one of the best ways.

I created a new directory off my root directory and then another directory in that one where I uploaded a index.php file with the code:

<?php
header("Location: myaffiliatelink");
?>

I did this but its not working. If anyone could help me with this I would be thankful
coreytucker is offline   Reply With Quote
Unread 29th December 2008, 03:38 PM   #2
Senior Warrior Member
War Room Member
 
Jesus Perez's Avatar
 
Join Date: 2008
Location: South Florida
Posts: 3,625
Blog Entries: 8
Thanks: 456
Thanked 1,436 Times in 731 Posts
Default Re: How To Do PHP Redirect In Wordpress?

Rename the index.php file to something like myaffiliatelink.php.

Then do a straight redirect including the php filename like so http://www.yourdomain.com/folder/myaffiliatelink.php.

That works for me.

Or you can get MaxBlogPress' Ninja cloaker for Wordpress. He just started a 2 day 50% discount this morning. MaxBlogPress Ninja Affiliate :: WordPress Affiliate Link Tracking Plugin

Jesus Perez is offline   Reply With Quote
Unread 29th December 2008, 04:05 PM   #3
Senior Warrior Member
War Room Member
 
Join Date: 2007
Location: , , .
Posts: 2,533
Thanks: 118
Thanked 65 Times in 59 Posts
Default Re: How To Do PHP Redirect In Wordpress?

well the thing about PHP redirect is it does not hide your affiliate link after it redirects. You can still see it in the search bar right? How do you hide the link on the seach bar also?

I would like to do this with a free method if possible. I also would like to avoid 3rd parties as I do not like the idea of having no control over this in case they go out of business etc.

So is there some sort of PHP or html code I can use to hide the hoplink on the search url also? I cannot seem to get it to work, im using a mutiple plan hosting account where I have alot of domains on one hosting account.

So I think all of the my sites are in the www folder and I click on the directory that is the name of the site im trying to do this one. Then I create another directory as im assuming this is the root directory and the right place to create a new directory.

I keep getting an error when I try to visit the link that should redirect to my hoplink url.
coreytucker is offline   Reply With Quote
Unread 29th December 2008, 04:14 PM   #4
Senior Warrior Member
War Room Member
 
Alan Petersen's Avatar
 
Join Date: 2006
Location: San Francisco, CA
Posts: 3,433
Blog Entries: 12
Thanks: 737
Thanked 840 Times in 523 Posts
Default Re: How To Do PHP Redirect In Wordpress?

What's the error you're getting? The way you're doing should work. Folder with a name of "recommends" or whatever. Inside that folder another folder with the product name and inside that a file with your redirect code named index.php. That means yourdomain.com/recommends/product_name should redirect. Make sure you don't have any spaces or extra characters in your code. One space will screw it up for you.

If you want to cloak the URL you need to do framed redirect. Here is the code:

Code:
<HTML><HEAD>
 <META NAME="description"
 CONTENT="http://www.yoursite.com/Recommends/">
 <META NAME="keywords" CONTENT="">
 </HEAD>
 <FRAMESET border=0 rows="100%,*" frameborder="no"
 marginleft=0 margintop=0 marginright=0 marginbottom=0>
 <frame
 src="http://YourAffiliateLinkHere.com"
 scrolling=auto frameborder="no" border=0 noresize>
 <frame topmargin="0" marginwidth=0 scrolling=no marginheight=0
 frameborder="no" border=0 noresize>
 </FRAMESET>
 </HTML>
Be careful because framedredirection violates most affiliate program TOS like ClickBank. The final destination URL should be visible on the end-users browsers window so double check the affiliate programs TOS before you try to use frame redirect.

Alan Petersen is offline   Reply With Quote
Unread 29th December 2008, 04:27 PM   #5
Senior Warrior Member
War Room Member
 
Join Date: 2007
Location: , , .
Posts: 2,533
Thanks: 118
Thanked 65 Times in 59 Posts
Default Re: How To Do PHP Redirect In Wordpress?

I just did it again and created only 1 folder this time and put a index.php file in it with the same code and the error I get is :

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/username/public_html/mysite.com/folder1/index.php on line 3

Parse error: syntax error, unexpected T_STRING in /home/username/public_html/mysite.com/folder1/index.php on line 3


I do not want to use frames as you said its against CB's TOS.
coreytucker is offline   Reply With Quote
Unread 29th December 2008, 04:28 PM   #6
Senior Warrior Member
War Room Member
 
Join Date: 2007
Location: , , .
Posts: 2,533
Thanks: 118
Thanked 65 Times in 59 Posts
Default Re: How To Do PHP Redirect In Wordpress?

I will say for the php file I simply opened up wordpad and saved the file as index.php
coreytucker is offline   Reply With Quote
Unread 29th December 2008, 04:28 PM   #7
Active Warrior
War Room Member
 
Join Date: 2008
Location: Ams, NE
Posts: 72
Thanks: 2
Thanked 7 Times in 7 Posts
Default Re: How To Do PHP Redirect In Wordpress?

Greets,
I think you heard wrong.

This is the best way so far...

1. Download this plugin
Link Cloaking Plugin for WordPress | W-Shadow.com

2. Install and Activate

3. Relax


Alternative plugin you can use:
WP-Affiliate PHP Blog Affiliate Marketing Wordpress Plugin | Seo Adventures
rarebiz is offline   Reply With Quote
Unread 29th December 2008, 04:37 PM   #8
Senior Warrior Member
War Room Member
 
Join Date: 2007
Location: , , .
Posts: 2,533
Thanks: 118
Thanked 65 Times in 59 Posts
Default Re: How To Do PHP Redirect In Wordpress?

Thanks rarebiz, but does this work well? Also how would I add a nofollow link using this plugin?

Redirect seems like the safer way but if I cannot get it to work I will use that wordpress plugin.
coreytucker is offline   Reply With Quote
Unread 29th December 2008, 04:44 PM   #9
Senior Warrior Member
War Room Member
 
Alan Petersen's Avatar
 
Join Date: 2006
Location: San Francisco, CA
Posts: 3,433
Blog Entries: 12
Thanks: 737
Thanked 840 Times in 523 Posts
Default Re: How To Do PHP Redirect In Wordpress?

You have bad data in your code. Use single ' ' instead of double " " for your URL code so it should be:

Code:
<?php
header('Location: http://www.youraffiliatelink.com');
?>
instead of:

Code:
<?php
header("Location: http://www.youraffiliatelink.com");
?>
Fix that and try again--it should work.


Last edited by Alan Petersen; 29th December 2008 at 04:47 PM. Reason: Added bold, color for emphasis
Alan Petersen is offline   Reply With Quote
Unread 29th December 2008, 04:52 PM   #10
Senior Warrior Member
War Room Member
 
Join Date: 2007
Location: , , .
Posts: 2,533
Thanks: 118
Thanked 65 Times in 59 Posts
Default Re: How To Do PHP Redirect In Wordpress?

I get the same error when I made the fix.

Is it ok to save a word file as .php?

Are you sure im in the root directory since im using a mutiple hosting plan? Thanks so much for the help
coreytucker is offline   Reply With Quote
Unread 29th December 2008, 05:00 PM   #11
Senior Warrior Member
War Room Member
 
Alan Petersen's Avatar
 
Join Date: 2006
Location: San Francisco, CA
Posts: 3,433
Blog Entries: 12
Thanks: 737
Thanked 840 Times in 523 Posts
Default Re: How To Do PHP Redirect In Wordpress?

Quote:
Originally Posted by coreytucker View Post
I get the same error when I made the fix.

Is it ok to save a word file as .php?

Are you sure im in the root directory since im using a mutiple hosting plan? Thanks so much for the help
Use a a text editor like Notepad not Wordpad. So copy and paste the code into notepad and save it as filename.php. Notepad comes with your PC so you should have that handy.

Alan Petersen is offline   Reply With Quote
Unread 29th December 2008, 05:02 PM   #12
Senior Warrior Member
War Room Member
 
Join Date: 2007
Location: , , .
Posts: 2,533
Thanks: 118
Thanked 65 Times in 59 Posts
Default Re: How To Do PHP Redirect In Wordpress?

ok oddly enough it works when I put the code into a notepad file instead of wordpad file,lol. Looks to be working!

Let me make sure though,lol. Thanks so much for the help.
coreytucker is offline   Reply With Quote
Unread 29th December 2008, 05:11 PM   #13
Active Warrior
War Room Member
 
Join Date: 2008
Location: Ams, NE
Posts: 72
Thanks: 2
Thanked 7 Times in 7 Posts
Default Re: How To Do PHP Redirect In Wordpress?

Quote:
Originally Posted by coreytucker View Post
Thanks rarebiz, but does this work well? Also how would I add a nofollow link using this plugin?

Redirect seems like the safer way but if I cannot get it to work I will use that wordpress plugin.
It works well and It's super safe.

Other easy way, you can use "Redirect" menu from CPanel which generate .htaccess

Don't use word. Sometimes word change the quote '' -> , "" -> automatically. It won't work on PHP.
Use plain text editor. Notepad or Notepad++.

Single or double quote doesn't matter in this case.
Using double quote you can process variables inside.

Example:
$world = "earth";
echo "hello $world";
echo 'hello $world';

Result:
hello earth
hello $world
rarebiz is offline   Reply With Quote
Unread 29th December 2008, 05:13 PM   #14
Senior Warrior Member
War Room Member
 
Join Date: 2007
Location: , , .
Posts: 2,533
Thanks: 118
Thanked 65 Times in 59 Posts
Default Re: How To Do PHP Redirect In Wordpress?

Yep it works! Thanks alot, your a life saver Im giving you a thanks!
coreytucker is offline   Reply With Quote
Unread 29th December 2008, 05:14 PM   #15
Senior Warrior Member
War Room Member
 
Join Date: 2007
Location: , , .
Posts: 2,533
Thanks: 118
Thanked 65 Times in 59 Posts
Default Re: How To Do PHP Redirect In Wordpress?

well how do you give thanks?
coreytucker is offline   Reply With Quote
Unread 29th December 2008, 05:15 PM   #16
Senior Warrior Member
War Room Member
 
Join Date: 2007
Location: , , .
Posts: 2,533
Thanks: 118
Thanked 65 Times in 59 Posts
Default Re: How To Do PHP Redirect In Wordpress?

also thanks rarebiz, but im just going to use the phpredirect.
coreytucker is offline   Reply With Quote
Unread 29th December 2008, 05:21 PM   #17
Senior Warrior Member
War Room Member
 
Alan Petersen's Avatar
 
Join Date: 2006
Location: San Francisco, CA
Posts: 3,433
Blog Entries: 12
Thanks: 737
Thanked 840 Times in 523 Posts
Default Re: How To Do PHP Redirect In Wordpress?

Cool, glad you're all squared away! Wordpad adds weird formatting stuff we can't see so it's best to always use a text editor like Notepad when you're tweaking code since--as you've seen--it's very sensitive.

Alan Petersen is offline   Reply With Quote
Unread 29th December 2008, 05:28 PM   #18
Senior Warrior Member
War Room Member
 
Join Date: 2007
Location: , , .
Posts: 2,533
Thanks: 118
Thanked 65 Times in 59 Posts
Default Re: How To Do PHP Redirect In Wordpress?

How do I give you a thanks Alan?
coreytucker is offline   Reply With Quote
Unread 29th December 2008, 05:30 PM   #19
Senior Warrior Member
War Room Member
 
Join Date: 2007
Location: , , .
Posts: 2,533
Thanks: 118
Thanked 65 Times in 59 Posts
Default Re: How To Do PHP Redirect In Wordpress?

oh and maybe you might know the answer to this. If im doing a redirect to this one page of my site could that be bad for SEO?

I mean I usually link to my product 2 times on each page and I have a 30 page site.

Also do you know if I even need to add a nofollow code to this link since its linking back a internal page in my site? Thanks
coreytucker is offline   Reply With Quote
Unread 29th December 2008, 05:42 PM   #20
Gleb
War Room Member
 
gesman's Avatar
 
Join Date: 2008
Location: Ottawa, Canada
Posts: 904
Thanks: 11
Thanked 133 Times in 97 Posts
Default Re: How To Do PHP Redirect In Wordpress?

The worlds best redirection plugin for wordpress is this:
http://urbangiraffe.com/plugins/redirection/
I use it to conceal affiliate links and "fix" renamed page - which it does automatically.
Also supports regular expressions if you're up to this.

Gleb

gesman is offline   Reply With Quote
Unread 29th December 2008, 05:43 PM   #21
Active Warrior
War Room Member
 
Join Date: 2008
Location: Ams, NE
Posts: 72
Thanks: 2
Thanked 7 Times in 7 Posts
Default Re: How To Do PHP Redirect In Wordpress?

I recommend to use "nofollow" though it might not necessary.
It should be okay because you don't user permanent redirect like this:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.someafiiliatelink.com/");
exit();
?>

But, it's best practice to use "nofollow" though, especially if you don't want outbound link spilling out. Every spider bot work differently.

Your redirect method is on server side. Which means you're not linking to your internal page, but to redirect destination.

And btw, thanks button is in the right bottom corner of each post.
Quote, Multiquote, Quick Reply, and the one you're looking for
rarebiz is offline   Reply With Quote
Unread 29th December 2008, 05:50 PM   #22
Senior Warrior Member
War Room Member
 
Join Date: 2007
Location: , , .
Posts: 2,533
Thanks: 118
Thanked 65 Times in 59 Posts
Default Re: How To Do PHP Redirect In Wordpress?

alright thanks everyone! I gave you guys thanks. I will go ahead and use the nofollow link and see how that goes. Have a great night all
coreytucker is offline   Reply With Quote
Unread 7th January 2009, 11:00 AM   #23
Warrior Member
 
Join Date: 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: How To Do PHP Redirect In Wordpress?

Hi, i just started a wordpress blog. It is hosted by wordpress itself. Can someone give me a step by step guide to do a php redirect? I'm new to this. Thanks in advance.
imnoob is offline   Reply With Quote
Unread 7th January 2009, 11:40 AM   #24
Mobile Apps Warrior
War Room Member
 
zoobie's Avatar
 
Join Date: 2007
Location: hong kong
Posts: 1,008
Blog Entries: 2
Thanks: 4
Thanked 45 Times in 41 Posts
Default Re: How To Do PHP Redirect In Wordpress?

well imnoob first you need a plugin that allows to run php inside wordpress and it's called phpexec. Do a search in google and find the download link.

After you upload to the plugin folder in your wordpress installation,
("wp-content/plugin" I think it's the directory) then go to your admin panel and activate it. Once you have done the step above,

by the way why you want to do this? imnoob. the normal command is
PHP Code:
<?php
header
'Location: http://www.yoursite.com/new_page.html' ) ;
?>
but you can't do it normally inside your post as wordpress returns you error.
you have to create an empty page template inside the wordpress and use the redirection code above

hopes that help.
zoobie is offline   Reply With Quote
Unread 7th January 2009, 09:08 PM   #25
Warrior Member
 
Join Date: 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: How To Do PHP Redirect In Wordpress?

Hi Zoobie, thanks for the reply. Is there other ways I can do php redirect without installing anything?
imnoob is offline   Reply With Quote
Unread 2nd March 2011, 06:17 PM   #26
Warrior Member
 
Join Date: 2011
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
Default Re: How To Do PHP Redirect In Wordpress?

O wow!
I see this is a bit older thread, however I found another option that worked for me..............

After copy/pasting the php code into notepad and using filezilla to upload to my "recommends" folder, it would just not work....

Finally I was able to look in my /wp-content/ folder in filezilla and copied the php code directly into the index.php file......then I used somebody above's suggestion of renaming the "index.php" to "product.php"

This worked & the code was exactly the same..!

So while making my own notepad file did NOT work....copying and pasting the code into the index.php and then renaming & moving that file to the "recommends" folder DID work.

Hope this helps anybody else having the same issue. !!
JTull is offline   Reply With Quote
Unread 3rd March 2011, 01:10 AM   #27
WebNinja
 
jminkler's Avatar
 
Join Date: 2010
Location: Atlanta GA
Posts: 443
Thanks: 19
Thanked 53 Times in 33 Posts
Default Re: How To Do PHP Redirect In Wordpress?

Here is what you all are probably missing

When you save a file in notepad ...

Filename:
myphpfile.php

Type:
<you must select All Types here>

If you leave it as the default the file end up being

myphpfile.php.txt

And you won't see it cause usually the file extensions are hidden on windows, so you have to select all types.
jminkler is offline   Reply With Quote
Reply

  Warrior Forum - The #1 Internet Marketing Forum & Marketplace > Warrior Support Forums > Programming

Bookmarks

Tags
php, redirect, wordpress

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 05:47 PM.