Using .htaccess files to make your web site or blog to redirect/cloak affiliate links or improve SEO is a great idea. Unfortunately Wordpress rewrites the file whenever you make a change to the blog layout or permalink structure.

Does that mean you can’t use custom .htaccess commands with Wordpress? Of course not, but you do need to make the right modification to the initial .htaccess it creates.

Here’s an example to show you how simple it is. Just move the lines in bold from their position in the first sample to the position in the second:

SAMPLE 1:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^yoursite\.com [nc]
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]

RewriteRule ^dummyurl$ http://www.affiliateservice.com/afclick.php?o=6496 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>
# END WordPress

SAMPLE 2:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^yoursite\.com [nc]
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]

RewriteRule ^dummyurl$ http://www.affiliateservice.com/afclick.php?o=6496 [L]

# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

</IfModule>

NOTES:

1. If you already have a .htaccess file in place be sure to save it off the server before installing a new Wordpress blog. You will then need to integrate the original code into new .htaccess file if Wordpress botches things and overwrites the whole thing. It doesn’t always happen but is a good thing to keep in mind.

2. The extra .htaccess commands above show first, how to make all requests to your site start with www. for SEO purposes, and second, a simple .htaccess redirect. I will be explaining the redirect in detail in upcoming posts.

Blogged with the Flock Browser

Tags: , , , ,

Would you like to Digg! a page with only one click? Here’s the “code”. I know this works in Firefox & Flock.

At any page drag the url favicon to the favorites tool bar.

Right click the newly created favorite item and select properties.

Change the name, I use DiggIt, it’s short so it doesn’t take up much space on the toolbar.

Past the code below into the address box. I have broken it into several lines so you can read it, but it needs to be all 1 line with no spaces:

javascript:location.href=’http://digg.com/submit?phase=3&
url=’+encodeURIComponent(location.href)+’
&title=’+encodeURIComponent(document.title)

You probably can’t read the line below but it is the entire code for copy and paste:

javascript:location.href=’http://digg.com/submit?phase=3&url=’+encodeURIComponent(location.href)+’&title=’+encodeURIComponent(document.title)

If you are logged in this will begin the Digg! process automatically, otherwise you will go to the log in page.

A quick screen capture video of this process will follow shortly.

Blogged with the Flock Browser

Tags: , , ,

Now you are going to use one PHP page to manage multiple link cloak/redirections. Again feel free to copy and paste the to make things easier.

The single page PHP redirect method removes all three of the drawbacks found in the original HTML version but adds a challenge of it’s own:

1. You have to add a parameter to the posted URL

For those of you not familiar with what that means here’s an example:

http://www.realcooldomain.com/hotproduct?g=31

The question mark signals the beginning of a parameter string (you can add multiple parameters but that’s for later). In the example above g is the parameter’s variable name and 31 is the value.

We’ll see how that works out in a minute.

One advantage of this method is code can be added to log visits directly to a database, like MySQL, which makes tracking and analysis easier.

Another advantage is a centralized page for managing a set of related cloaked links (or all of them if you want).

It will be up to you to decide if these advantages outweigh the need for ?g=31

IMPORTANT REMINDER:

It is very important that the PHP code containing the header command show up in your document before any HTML. Get into the habit of putting all redirects before even the “DOCTYPE” HTML line.

Make sure there are no blank lines at the top of the page. This is probably the number one mistake that causes the redirect to fail.

Redirecting multiple links on one page is not as straight forward as one line php redirects. Instead of a direct step by step I will show you how the sample code (at the bottom for you to copy and paste) is built. This will help you understand how you can add a new link direct with one simple copy and paste operation.

The first line:

switch ($g) {

tells PHP to look at the value of the variable g. So if your link is:

http://www.realcooldomain.com/recommends.php?g=hotproduct

PHP will use the value hotproduct in the lines that follow.

The next three lines:

case “hotproduct”:
header(’Location: http://www.iphone.com’);
exit;

ask 1. if the variable g is hotproduct 2. then redirect the browser to http://www.iphone.com and 3. stop running php.

If the variable g is not hotproduct then the next line starting with case, if it exists, will be evaluated.

The exit; is very important. Without it the lines that follow will be run and only the default redirection will occur (see below)

The three lines shown above are technically enough to make this work. If you leave off the default section and the variable is not set to hotproduct then the HTML at the bottom will be shown. You can use any standard HTML page below the PHP code.

To create additional redirects just copy the three lines of code, paste above default: and below the last exit;, and change:

http://www.iphone.com

to the URL you want people to end up at.

For this example I decided I wanted:

http://www.realcooldomain.com/recommends.php?g=apple

to go directly to the Apple home page. The result is:

case “hotproduct”:
header(’Location: http://www.iphone.com’);
exit;
case “apple”:
header(’Location: http://www.apple.com’);
exit;

The final three lines of PHP in the sample code below are optional. If no variable is matched you can leave them at this page and they will see any HTML you enter below the PHP.

If you want everyone to go to a specific site, like an offer that converts well on general traffic, keep this:

default:
header(’Location: http://twitter.com/mfartr’);
exit;

and change:

http://twitter.com/mfartr

to the page you want everyone sent to.

Next up, using .htaccess for all your link cloaking and tracking needs.

Here’s the code to copy.

<?php
switch ($g) {
case “hotproduct”:
header(’Location: http://www.iphone.com’);
exit;
case “apple”:
header(’Location: http://www.apple.com’);
exit;

default:
header(’Location: http://twitter.com/mfartr’);
exit;
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″ />
<title>Untitled Document</title>
</head>

<body>
whatever you want here
</body>
</html>


July 14th, 2008

Technorati: affiliate link  link cloaking  php redirect  redirect  

This post contains two methods to cloak and redirect an affiliate link using PHP. Again feel free to copy and paste the to make things easier.

You are going to use a single line of PHP to redirect the user to the final destination just like the HTML method.

The single line PHP redirect method has two of the three drawbacks found in the HTML redirect method:

Affiliate Link Cloaking, A Step Up With One Line Of PHP» [more]


June 27th, 2008

Technorati: affiliate link  affiliate marketing  link cloaking  

Feel free to copy the code snippet at the end of this post and use it for your own redirects.

There is no simpler way to cloak an affiliate link with a simple line of HTML code. It’s called an HTML redirect and uses an HTML meta tag, http-equiv=”refresh”, that is supported by all modern browsers on all operating systems.

The piece that does the work is the content parameter and it has two parts, each separated with a semicolon.

Affiliate Link Cloaking The Easy Way» [more]


June 27th, 2008

Technorati: affiliate link  affiliate marketing  link cloaking