How to create redirect all external links in wordpress

If you are running a affiliate website and you want to cloaking and redirecting all external links in your website ? So in this tutorial we will show you How to create redirect all external links in WordPress.


Example external link:

Url alias to redirect to an outside site:

Now following the instructions bellow:

Step 1: Download this file: [Download not found] . Open it and change this line to your address

[code lang=”js”]a_to_ve[i].href = "" + a_to_vi;[/code]


[code lang=”js”]a_to_ve[i].href = "" + a_to_vi;[/code]

Step 2: put this code in your file “footer.php” of your theme

[code lang=”js”]
//link to this js file you have downloaded above
<script src="" type="text/javascript"></script>
<script type="text/javascript">
//name of the sites that you want to exclude. only the name.
protected_links = "myspace,ebay";
<!–script at the end of the body–>


Step 3 : Finally, create a file called “redirect.php” in your root directory with the code:

[php]//get the link
$str = $_GET[‘url’];

if ($str == ”) {
//if the variable URL link is empty. eg "…/redirect.php?url=" or "…/redirect.php" then redirects to home.
} else {
//otherwise redirects the external site.
header(‘Location: ‘.$str);

Done !

If you have any problem, Please use comment box bellow !

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Free Designsave Spinner 100% Unique & Readable!Free Spinner