Using .htaccess Redirects for Affiliate Links

.htaccess redirect

Editing the .htaccess file can make your website inaccessible if done incorrectly. Always make sure you have a back-up of the current version of the .htaccess file, to go back to a working version.

.htaccess is a file on Apache servers. It’s a very powerful tool, but often requires rather detailed technical knowledge to edit. Thankfully it’s not that difficult for the purpose of redirecting pages on server level.

Step 1: Check for existing .htaccess
First you need to find out whether you have a .htaccess file already. Start your FTP-program (make sure your program shows the .htaccess file), browse to the root of your domain and look for it (it’s usually on top of the list). If it’s there, download it. Make sure to make a back-up of the current file!

Step 2: Edit it to add redirects
Open the .htaccess file in a text editor and add the following lines to the file.

# Temporary redirects for affiliate links
Redirect 302 /[subdir]/[filename] http://example.com/?id=12345
Redirect 302 /[subdir]/[filename] http://example.com/?id=34567
# End of affiliate redirects

Now replace /[subdir]/[filename] with the right link, and replace http://example.com/?id=12345 with the address you want to send your visitors to when they click the link.

Make sure you use a temporary redirect. The status code 302 tells the other server that the page is redirected temporary, and that they should not update their addresses to the new address.

For example, for my e-junkie affiliate link this looks like this:

Redirect 302 /go/e-junkie.php http://www.e-junkie.com/?r=11261

Step 3: Save and upload
Upload and overwrite the old .htaccess file on the server.
Again make sure you have a back-up of the old version before you do this!

Step 4: Link to it.
That’s it, now use that link instead of the original link. It doesn’t even matter if there’s a file or not on the original location.

Again, use caution with this file. Make sure you have a copy of a working version and ftp-access to your server in case things go wrong. An error in the .htaccess file could effectively deny you access to the WordPress Admin interface. In which case you’ll have to replace the erroneous file with the back-up through FTP.

Advertisements

3 thoughts on “Using .htaccess Redirects for Affiliate Links

  1. Personally, I alway like using PHP redirectional scripts when it comes to affiliate links. It seems the major search engines devalue web pages with lots of affiliate links and I’ve seen the best results when using PHP redirectional scripts.

    Like

  2. Don’t for get to add the /go folder from your example to the robots.txt disallow list or you will end up with a bunch of empty pages in the search indexes and this may lead to penalties!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s