How to automatically short all links on main site with safelink from a subdomain

How to automatically short all links on main site with safelink from a subdomain

Many bloggers have started implementing the safelink option allowing them to encrypt all external links on their blog. This way, they can gain traffic and earnings.

One big issue many faces with this is the need to encrypt the links manually. Here, we are going to show you how to automatically short all links on the main site with safelink from a subdomain.

That is, this guide will come in handy if for example you are having a Blogger Blog www.example.com and you have created a subdomain download.example.com for this site to direct all external links using the safelink template.

To demonstrate this, we have one of our blog where we share Apps for iOS and Android as well as iOS tips and IPSW files. itsappleos.com has a subdomain(dl.itsappleos.com) with the safelink template and we can manually encrypt all download links to pass through it. Encrypted links open via a random post and the destination link is encrypted using Base64 encryption.

But having to encrypt the links manually is quite tedious and time-consuming. So, why not do it automatically?

Well, most of the Safelink Blogger templates come with a script you can add to your main site and it will encrypt all other links automatically. But the issue is how to use it.

How to auto-encrypt main site links with safelink from a subdomain or another site

  • For a start, you should have a safelink site like the one we have here. You can equally use for a safelink site that isn't a subdomain of your main site.
  • Next, copy the script below and paste it just above the closing body tag </body> of your main site.



<script type='text/javascript'>
//<![CDATA[
var setting = {
exceptionurl : "google.com,twitter.com,telegram.me,youtube.com,youtube.be,instagram.om,pinterest.com,whatsapp.com,line.me,tumblr.com",
path : "#?o="
};
//]]>
</script>
<script src='https://raw.githack.com/mghifariarfan/linkpunyaku/master/auto.js'></script>
<script src='https://www.blogger.com/feeds/2663039376943509674/posts/default?alt=json-in-script&max-results=150&callback=showurl'></script>

In the above script, perform the following modifications:
  1. Add the links you do not want to get encrypted where you see "exceptionUrl" We have two links there. google.com and twitter.com. Add your blog link there. Make sure to add the link of any other service you use for post sharing else it will create issues when trying to share your posts to the given social media. We have added for most of them.
  2. Next, replace "2663039376943509674" with the ID of your safelink blogger blog (ID of your Blogger URL encrypted or shortener). The ID of your Blog is the number you see on the dashboard URL. So the dashboard address will look like this https://draft.blogger.com/blog/posts/YOUR_ID 
  3. In some safelink templates, the path is represented as #?url= or #?id=, you will have to change this too to match that of your safelink template. Just short a link manually and see the path if it isn't #?o=, change it on the script.
  4. After performing these modifications, save your theme.
Now all your links on the main site will get automatically encrypted and will open via your safelink site.

Having a hard time applying this? Leave a comment below and we will for sure get back to you.
أحدث أقدم