If you use a lot of affiliate links in your WordPress site, you will find over time that they will become broken – this is down to websites changing their URLS, swapping affiliate management to different systems and discontinuing products etc. It’s quite an annoying problem to deal with as not all companies will notify you or you miss the email that they might send out.
That’s why it makes sense to audit your affiliate links every now and then, if you have just pasted the affiliate links directly into your posts, this can be a problem so I recommend that you use an affiliate link manager plugin to handle them. One such plugin is Thirsty Affiliates, I also listed a few more in my post “Monetize your blog with Affiliate links, Plugins & Advice“.
Most plugins will save redirected URLS to your .htaccess file which is how we will get a list of URLS we can test, read on to see How to Audit Your Affiliate Links.
Get a list of Your Affiliate URLS
The first thing to do is download a copy of your .htaccess file which is located in your website root folder ( public_html ) and locate the affiliate redirected links, which will look like this :
Redirect 302 /8bitlivetheme https://www.e-junkie.com/ecom/gb.php?ii=838957&c=ib&aff=270272&cl=64302 Redirect 302 /academiablackboard http://www.academiathemes.com/members/aff/go/wplift/?i=1 Redirect 302 /academiafoundation http://www.academiathemes.com/members/aff/go/wplift/?i=12 Redirect 302 /academialectura http://www.academiathemes.com/members/aff/go/wplift/?i=3 Redirect 302 /academiaprincipal http://www.academiathemes.com/members/aff/go/wplift/?i=2 Redirect 302 /acosmin https://www.e-junkie.com/ecom/gb.php?cl=50612&c=ib&aff=270272
Now you will want to extract the actual URLS so you can test whether they are live or broken, to do this I found this tool called URL extractor which let’s you paste in some text and it will extract all the URLS and make them links.
Once you have the URLS, copy and paste them into a blank file and name it something with a .html extension, upload this somewhere online to your website where it can be accessed and you can then test them.
Test the URLs for Dead Links
To check your list of URLs for dead links, visit Dead Link Checker and enter the URL of the file you created with all your affiliate URLS listed. Choose “Quick Scan” which only checks the URLS in a single web page, choose “automatically retry dead links 2 times” and click the “check” button and it will begin scanning your links for you.
Article continues after this block
Depending on how many links you have to check, this process may take a while so leave it running and eventually you will get a report which lists any broken URLs, like so:
Some of the errors could be 400 (Bad Request), 404 ( Page Not Found ), Timeout or Not Found. You should save the list of bad URLS and then manually go through them by hand and see what the problem is. Out of 748 links and the checker found 115 with problems – I checked and the timeouts were ok, the site was just taking a while to respond so I left those links as they were.
Others, the website was gone so the affiliate program was also closed – some of the 404 errors were companies which had changed their affiliate system.
After finding all the links where the website had closed and the ones where the affiliate program had changed, its a good idea to signup for the new affiliate program and change the links over in your link manager. For the ones where the website had closed, you can go and delete the links in your posts to that, or if there is a similar website / link you can simply swap them over to something else.