Automatically Convert all external links to affiliated links

Avg Bid (INR)
Project Budget (INR)
₹1500 - ₹12500

Project Description:
I would like to be able to automatically change links into affiliate links on my Wordpress and Mybb installation. This would help to reduce the amount of time managing links in case the code needs to be changed in the future as you know advertiser keeps changing the affiliate websites from one another.

This is my setup of affiliate scheme. If the url is suppose :
I need to make it this :-

I also need to have a http:// always before starting if its there, it ok, if its not there, then i need to add it otherwise it wont be redirected correctly.

The same Kind of thing is here : Change all website links to affiliate links automatically

But this talks about appending the code at the end only, whereas i have to append the code at the beginning too. Also this doesn't talk about adding http:// in the beginning everytime. Can anyone help me with this?

Thanks you.

Skills required:
MySQL, PHP, Software Architecture
About the employer:
Public Clarification Board
Bids are hidden by the project creator. Log in as the employer to view bids or to bid on this project.
You will not be able to bid on this project if you are not qualified in one of the job categories. To see your qualifications click here.

₹ 12000
in 30 days
₹ 10000
in 3 days
₹ 7368
in 33 days