How to Mask Affiliate URLs

Many affiliate links are long, ugly looking things that make savvy surfers think twice about clicking them. Wouldn’t it be nice to dress them up a little or completely shorten them into something more memorable? Welcome to the beautiful world of link masking. Yes, we can hide affiliate links if we want to.

There are two ways to hide link targets:

  1. URL redirects
  2. URL masks

URL Redirects can be done with a meta refresh, a URL rewrite or with a URL shortening service.

URLs can be masked by adding a few extra items to link <a> tags.

Meta refresh

A meta refresh can be used to tell a web browser to refresh a page after a given time and redirect visitors to a specified URL.

For this to work we create an HTML file with an attractive looking URL, add the following HTML code to it with the text ‘AFFILIATE URL’ replaced with the URL of the affiliate link, then use the link to the HTML file whenever we want to send people to our affiliate website.The HTML

<html>
<head>
<title></title>
<meta http-equiv="refresh" content="0;url=AFFILIATE URL" />
<style></style>
</head>
<body></body>
</html>

The active bit of code is this:

<meta http-equiv="refresh" content="0;url=AFFILIATE URL" />

The HTML page can be given any URL that doesn’t look like an affiliate URL e.g http://example.com/learn-the-secrets.html or http://example.com/make-money-now.html.

When sending visitors to the affiliate page, instead of sending them to http://this-big-ugly-affiliate-link-is-sooo-obvious.com you can now send them to the HTML page created to redirect them there.

htaccess 301 redirects

To set-up a 301 redirect

  1. Open the .htaccess file in your site’s root directory
  2. Add the code on a line of its own
    Redirect 301 /some-short-url http://example.com/affiliate-link
  3. Repeat step 2 for each affiliate link
  4. Send visitors to some-short-url and they will be redirected to http://example.com/affiliate-link

URL shortening services

There are many URL shortening services. Too many to mention them all. Two respected URL shorteners are:

If you use WordPress you can create your own URL shortening service by using a plugin like Pretty Links.

URL masking

Links can be masked by adding a few extra attributes to link anchor tags. This doesn’t involve any redirects and causes web browsers to report a false URL to the visitor. The code for a masked link looks similar to this:

<a href="FAKE URL" onclick="document.location.href = 'REAL URL'; return false;" title="ANCHOR TEXT">CLICK HERE</a>

A typical <a> tag looks like this

<a href="REAL URL" title="ANCHOR TEXT">CLICK HERE</a>

The masked URL uses onclick and return false to hide the real URL.

For example, to mask a link to http://this-affiliate-link-is-sooo-loong-and-ugly.com by covering it with http://nice-and-simple.com, just create an <a> tag as

<a href="http://nice-and-simple.com" onclick="document.location.href = 'http://this-affiliate-link-is-sooo-loong-and-ugly.com'; return false;" title="ANCHOR TEXT">PRETTY LINK</a>

If you use WordPress, the WordPress visual editor will filter out the link masking so enter masked links in the non-visual text editor.

Sharing is caring!

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments