Need idiots guide for using htaccess for aff redirects

by Teesd
11 replies
Hi there Warriors,

I'm new not only to this forum, but to the internet marketing in general. I have scanned this forum for previous topics, but my head is just spinning...

I have a niche website using Wordpress and have signed up for several affiliate programs around my chosen topic. In order to protect my commissions I want to use htaccess for redirecting my URL's. I also want to avoid Wordpress plugins since I'll be linking to hundreds of products over the month ahead.

First question, is this the most effective method for redirecting links? I'de like to avoid creating a separate file for every single product on my site.

Would anyone be able to give me a step by step complete idiot's instruction for creating my redirects? Also details on where I should be inserting my code and do's/don'ts for working with htaccess. (my biggest fear is messing up my webfiles)

If it will help, this is my current setup: Blog using the most current version of Wordpress and hosted on Bluehost and Cpanel.

If anyone can provide the least technical, path of least resistance method for a complete newbie I'll forever be grateful...
#aff #guide #htaccess #idiots #redirects
  • Profile picture of the author Brandon Tanner
    Hey Teesd,

    .htaccess is the quickest and "smoothest" way to redirect links, because it redirects without actually serving up any webpages on your site. The only drawback with this method is that your can't track your redirected visitor "hits" with it (because it never serves up an actual webpage from your end when it redirects). So if those stats are not important, then do an htaccess redirect. If those stats are important, then you'll need to do a conventional html or php redirect.

    Here's how to do .htaccess redirects...

    You can put as many redirects as you want in a single .htaccess file. Check your 'public_html' folder (via an FTP program), and see if there is an .htaccess file there. If not, create a new one (just create a blank .txt file on your desktop, and upload it to your 'public_html' folder via FTP, then rename it to .htaccess

    Then put each redirect on a separate line in the .htaccess file, in the following format (NOTE: if an .htaccess file already existed, then just add your redirects to the lines below any code that already existed in the .htaccess file)...

    Redirect 301 PathToRedirectFileOnYourWebsite/RedirectFile.html http://www.YourAffiliateLink.com

    Then you would give your prospects this link --> PathToRedirectFileOnYourWebsite/RedirectFile.html
    Which would redirect to --> http://www.YourAffiliateLink.com

    Make sense?
    Signature

    {{ DiscussionBoard.errors[3280772].message }}
  • Profile picture of the author donnan
    Hi,

    It's pretty easy to redirect any page to another site or page.

    First open your .htaccess file.

    Goto the bottom of the file and add your redirect line

    In the first part of the redirect you must show the path to the page on your server, NOT the url.

    redirect 301 /home/public_html/mypage.html http://www.thedestination.com/somepage.html

    Save your .htaccess and upload it back to your server.

    When a user goes to http://www.yoursite.com/mypage.html they will be redirected to the new url.
    {{ DiscussionBoard.errors[3280807].message }}
    • Profile picture of the author Brandon Tanner
      Originally Posted by donnan View Post

      Hi,
      In the first part of the redirect you must show the path to the page on your server, NOT the url.
      Good point! I forgot about that... have updated my example.
      Signature

      {{ DiscussionBoard.errors[3280871].message }}
  • Profile picture of the author donnan
    It's easy to forget sometimes.
    {{ DiscussionBoard.errors[3281044].message }}
    • Profile picture of the author Teesd
      Thank you both for the help. I'm at my day job at the moment so I won't be able to try again until later tonight. I'll definitely check back afterwards to let you know how I made out.

      Thanks again!
      {{ DiscussionBoard.errors[3281314].message }}
  • Profile picture of the author SteveJohnson
    Lesson #1 from the School of Hard Knocks: before you start messing around with your .htaccess file, be certain you have a good working copy that you can upload in case of disaster!

    A misplaced comma, missing slash, or a misspelled word can cause your entire site to disappear behind the dreaded "500 - Server Error" message page. If that does happen, you need to have a good copy of the file that you can immediately upload to your server.
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[3281340].message }}
  • Profile picture of the author donnan
    I agree Steve, good advice.

    Sometimes people don't realise they need to have a backup just incase something goes dreadfully wrong.
    {{ DiscussionBoard.errors[3281404].message }}
    • Profile picture of the author Teesd
      Hi Steve,

      Thanks for your advice. That's the exact scenario that is giving me such anxiety. I have heartburn as I type this just thinking about it.

      What is the best way to obtain this working copy? I assume it would be a copy/paste from the existing file into a .txt file stored on my hard drive. But what if a .htaccess file doesnt exist and the file thats stored is the one I created for my server? Do I just delete it?

      This is scary...
      {{ DiscussionBoard.errors[3281507].message }}
  • Profile picture of the author donnan
    Teesd,

    If one exists, the file should be on your server. Sometimes it could be hidden though. Use your ftp program and right click your server after logging in and select "Show hidden files" If it's there it will show up.

    If not there, then just create one from an ordinary text doc. Upload it to your server and rename it .htaccess.

    Here is a typical .htaccess file tutorial
    301 Redirect - How to create Redirects

    PM me if you need any help.
    {{ DiscussionBoard.errors[3283089].message }}
    • Profile picture of the author Teesd
      uh oh.. i want to post my example code to verify if it looks alright, but i dont have enough posts, and I'm not allowed to PM either. Any suggestions? I saved a copy of my .htaccess file so i guess I'll experiment.
      {{ DiscussionBoard.errors[3284169].message }}
  • Profile picture of the author JohnyData
    If anyone is interested, I created a tiny little app which will create an HTML file with about 13 different types of redirect links including ASP, CGI, PHP, Java, CFM, etc...

    You can download it here: Redirect Link Generator (direct download link)

    Rest assured that there is NO ad ware, spy ware, call homes, splash pages, registration screens or any of that. Just a simple download, run, and use type of application.

    A browser window will appear when the software is finished as this is how you will see the page with the created redirect codes.

    This is a Windows based app so you must have Windows or I am sure it would work on Parallels if you are so inclined to try.
    {{ DiscussionBoard.errors[3284197].message }}

Trending Topics