Today i’m going to tell you on how to hide your affiliate links or any other links you want to hide (see the right sidebar of this site) using a simple htaccess redirect trick, just in case you didn’t know about it, and of course i’ve only tested this on Apache HTTP Server only (Windows and Linux version) so if you’re using any other webserver to serve your webpages … i’m quite sure that this trick is not going to work, and you’ll have to use some redirect script to do it
But as a side note, this redirect trick (or any other redirect trick using php, etc) may or may not working especially if your site mostly visited by tech savvy users even if the affiliate website itself didn’t show your referal link, because they can always see it through the HTTP header
Redirecting from the root of your domain name
Step to do it :
Open or create new .htaccess file on the root of your www / public_html directory and add this line :
Redirect /myaffiliate http://www.myaffiliatewebsite.com
the above line mean, if you type http://www.yourdomainname.com/myaffiliate it’ll be redirected automatically to www.myaffiliatewebsite.com using 302 Found HTTP Header
But what if you want a 301 Moved Permanently HTTP Header instead of 302 HTTP Header (almost every redirect trick i’ve seen so far is using 302) ? … if that’s what you want … then you can use this
Redirect 301 /myaffiliate http://www.myaffiliatewebsite.com
Redirecting from subdirectory
Step to do it
Redirect /redir/affiliate http://www.affiliatewebsite.com
The above line mean, if you type http://www.yourdomainname.com/redir/affiliate it’ll be redirected automatically to your affiliate link
Redirect to multiple product in the same affiliate website with a single line (useful on site like Amazon)
Let’s say you’ve become an Amazon Affiliate, and you want to link to that product page without adding new line into your htaccess file … then you can add this line into your .htaccess file
RewriteRule ^show/(.*)$ http://www.amazon.com/exec/obidos/ASIN/$1/YourAmazonID [L]
What the above line do is, whenever you type http://www.yourdomainname.com/show/ANY-AMAZON-PRODUCTID it’ll be redirected automatically to http://www.amazon.com/exec/obidos/ASIN/ANY-AMAZON-PRODUCTID/YOUR-AFFILIATE-ID
Another example on how to make your Amazon Link look pretty is you can also use this :
RewriteCond %{QUERY_STRING} id=([^&]*)$
RewriteRule ^products\.asp$ http://www.amazon.com/exec/obidos/ASIN/%1/YOURAMAZONID? [L]
Basically what the above code do is, everytime you type mydomain.com/products.asp?id=AMAZON-PRODUCT-ID even without the existence of products.asp file on your webserver, it’ll be redirected automatically to the Amazon link using your Referal ID :)
As a note, Mod Rewrite must be enabled on your server to do the last redirection trick
That’s it … i hope this small tips can be useful for you :)
Leave a response
Awesome tips…
I do have some questions though. Lets say I’m promoting a software that offer a free demo version download, but doesnt embded the affiliate links inside the .exe of the download demo.
How could I redirect my users so that to get the demo from me, they would:
1) pass through my affiliate link first to have the cookie set
2) then are redirected to the download .exe
Hope you can help! Thanks for all the cool tips.!
– Ryan
Have you ever been to a themed party where you dressed up accordingly?
Every year we have a themed party which includes costumes, food, music, backdrops to match.
Over the years we’ve had the following themes: China, Under the Sea, Colours, Out of Space, Countries, Black & White, Hawaii, History, Fairy Tales… Can’t think of anymore.
Anyway they are real fun, seeing what everyone dressed up as and how they interpredted the theme idea.
I’ve already come to the conclusion that one diet will work wonders for one person yet not make a slight difference to another.
What diets have you done that actually worked for you?
How long did you keep it up? (Yes I’m assuming you gave up at some point)
I’ve done many diets in my life and each time I gave up keeping it going for various reasons.
One does stand out though and that’s the cabbage soup diet. It is meant to cleanse your body of all the bad foods you’ve had and should only be done for one week since it is not a diet for life. I can say it really worked. My mum and I did it (I think 10 years ago) She lost about 3 kg in that week and looked no different in her appearance. I, on the other hand lost nothing, yet I looked great.
In a nut shell the diet consists of having a certain recipe for cabbage soup which you can eat as much as you want the entire week, and every day you eat something else (can’t remember the list though..)
How about you?
I think Burger King is the better fast food joint out of the two of these. The burgers taste better, the fries taste better, the have WAY better pies and the only thing McDonalds does better than them is the chicken nuggets.
So my sister is 10 years old, and has been addicted to board games lately. She asks me like 5 times a day to play the game Life with her or Apples To Apples. So it got me this idea to make this thread.
I would like to know what is your favorite board/card/dice/etc. game, and what was your favorite board/card/dice/etc. game as a child?
My favorite board game is Clue, cause it is not like other board games in my opinion and keeps me entertained. I loved Clue as a kid, and I still do. Other games I enjoy are Uno and Apples To Apples.
I don’t have a link to the story. I saw it on our news and read the article in our paper today.
A woman was pregnant with triplets. For some reason (they didn’t disclose for privacy purposes), one of them was born (not even by c-section but natural way) at 25 weeks and the doctors were successful in stopping the other two from coming out.
So now the woman is taking care of the preemie and is still pregnant with twins. In this case, are they still called triplets?
Anyone heard a familiar case? Supposedly, this is becoming more common especially for pregnancies due to fertility treatments/methods.
Thanks for the tips Reaper. I’m going to implement these .htaccess techniques ASAP.
I enjoy your site very much! THANK YOUO
Thanks for your project. I like this site. KEEP IT UP..n
good technique
I’m going to use this technique also
# Layton
I’m really sorry for late reply because i didn’t see your comment
about your question, could you try using the amazon code using the RewriteCond code? because it seems that you want to redirect query string
Sorry, the code was this:
RewriteRule ^out/(.*)$ http://www.amazon.com/exec/obidos/ASIN/$1/myamazonID
Hi,
I’m having a bit of trouble with this. On my site the out link displays as a friendly URL:
http://www.mydomain.com/out.php?title=Amazon-com_The_Orange_Box_Video_Games_Windows
I tried using this code in the htaccess file:
RewriteRule ^out/(.*)$ http://www.amazon.com/exec/obidos/ASIN/$1/myamazonIDbut it didn’t work. I also tried placing a regular Amazon.com link to see if the redirect worked but it didn’t. Is the above code wrong?
Thanks. Great site.
Your welcome, hope it’ll be useful for you :)
Excellent tip. I’m going to use this technique to see how it works for me. Thanks again.
Great tip on the Amazon referral link, I hadnt even thought about that when I was searching for the first tip.