I came across this coupon website that uses a URL structure something like the below one for its affiliate links.


When clicked on the link, it will be automatically redirected from example.com to http://tracking.affiliate-link.com&aff_id=123

I know there are a lot of plugins for WordPress that let you cloak the affiliate links. But those plugins require you to manually add the links in the plugins page first.

I was wondering how to achieve the above shown redirect. That is, simply add https://example.com/?offers=/ in front of the actual affiliate link and it should be redirected.

Is there anyway I can achive this?


You can add ?offers=/http://tracking.affiliate-link.com&aff_id=123 after your link and then check in the destination page (in this case the homepage) if is set $_GET['offers'], and in the case that it is, redirect to the content of the var, which is the url.

In the Wordpress system I would create a page called "Offers" that would be in example.com/offers. You can create a page template attached to this page, and there check if the link sent by get parameters is what you want, and in case it is, redirect the user.

A simple page template would be something like this:

<?php  /*   Template Name: Offers   */ ?>
<?php if(isset($_GET['offers'])){
    wp_redirect( $_GET['offers'] );
} ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.