Subscribe to my YouTube Channel
 
Subscribe to Affiliate Tip

7175

Readers... and growing!
Subscribe Form

Use .htaccess Redirects

Posted by shawn on December 5th, 2004 | 3 Comments

Thanks for visiting the Affiliate Tip blog. Subscribe to my RSS feed or enter your e-mail on the top left to get updates by e-mail.

There are many reasons to redirect affiliate links, such as the ability to shorten them for text newsletters, and cloaking your links.

The most common was to redirect links is with a META refresh tag or a JavaScript. This is easy enough, but there’s an even better, easier way to redirect your links: the .htaccess redirect.

An .htaccess file is a plain ASCII text file you place in the root directory of a Unix server. The .htaccess technique is much easier than using other redirects, because there’s no HTML required. All of your redirects are in one text file.

.htaccess uses redirect to look for any request for a specific page (or a non-specific location, though this can cause infinite loops) and if it finds that request, it forwards it to a new page you have specified.

For instance:

Redirect /olddirectory/oldfile.shtml http://www.yourdomain.com/newdirectory/newfile.shtml

In the example above, there are three parts, and they should all be on one line:

  • the Redirect command
  • the location of the file/directory you want redirected relative to the root of your site (/olddirectory/oldfile.shtml = yourdomainsite.com/olddirectory/oldfile.shtml)
  • the full URL of the location where you want to redirect

Each of the three parts is separated by a single space, and all must be on one line. You can also redirect an entire directory by simply using:

Redirect /olddirectory http://www.yourdomain.com/newdirectory/

Using this method, you can redirect any number of pages no matter what you do to your directory structure.

Please note – you should be careful if you’re going to edit an existing .htaccess file. Before making any changes, make a copy of the original file, so if you make any mistakes, you’ll still have the original file.

  • Posted in Affiliate Tips
3 Comments
  1. On June 21 @ 8:22 pm zorozorov said

    Thank you for great information. This post helped me a lot.

    reply to this comment
  2. On June 21 @ 10:22 pm zorozorov said

    Thank you for great information. This post helped me a lot.

    reply to this comment
  3. On February 4 @ 11:10 pm Daniel M. Clark said

    I've been using PHP redirects, but I'm unhappy with the link structure: .com/visit?destination – so I've been planning (for like, six months!) to give htaccess a shot. Thanks for reminding me.

    reply to this comment
Have an opinion? Leave a comment?

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent photos
Google Friend Connect

Bad Behavior has blocked 6481 access attempts in the last 7 days.