Shawn Collins' Blog

Affiliate marketing and other stuff from Shawn Collins, co-founder of Affiliate Summit.

  • Home
  • About Shawn
  • Contact
  • Learn Affiliate Marketing
  • Disclosure
  • Archives

Use .htaccess Redirects

December 5, 2004 by Shawn Collins

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

Thinking

Thinking

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.

Share this:

  • Twitter
  • LinkedIn
  • Facebook
  • Reddit

Related

Filed Under: Affiliate Tips

Shawn includes advertising links in some posts - these do not influence the content, and they promote products and services he uses.

Social

  • View shawncollins’s profile on Facebook
  • View shawncollins’s profile on Twitter
  • View shawncollinsatx’s profile on Instagram
  • View affiliatetip’s profile on Pinterest
  • View shawncollins’s profile on LinkedIn
  • View affiliatetip’s profile on YouTube

Blogroll

  • Affiliate Manager
  • Austin FC
  • Austin, TX Airbnb
  • Bose Hearing Aids
  • Extra Money Answer
  • Movies That Affected My Life
  • This is Affiliate Marketing

Return to top of page

Copyright © · Shawn Collins Consulting ·

 

Loading Comments...