Link shortening codes for websites

الغــــــــــازي
الغــــــــــازي Published on August 22, 2024

This script allows you to shorten all (or shorten) link addresses on your website very easily. All you have to do is copy and paste the code below at the end of your page. You can customize the selector as you like to target URLs in a specific selector. Note that you can just copy the code below because everything is ready for you.

 

<script type="text/javascript">var key = "2b2614538225c4898e88c66c32238157";</script>

<script type="text/javascript" src="https://2h.ae/script.js"></script>

 

Choose a different domain:

By default, the script uses the default domain on the platform but you can specify a custom domain name to shorten links with. You need to make sure that the domain is exactly the same as the domain added in the account, including the schema (http/https)

 

<script type="text/javascript"> var key = "2b2614538225c4898e88c66c32238157"; var domain = "https://mydomain.com"; </script>

<script type="text/javascript" src="https://2h.ae/script.js"></script>

 

Choose custom settings

By default, this script shortens all link addresses on the page. If you want to target specific link titles, you can add a selector parameter. You can see an example below where the script only shortens URLs of links that have a class called mylink or all direct links in a .content container or all links in a .comments container.

 

<script type="text/javascript"> var key = "2b2614538225c4898e88c66c32238157"; var selector = ".mylink, .content > a, .comments a"; </script>

<script type="text/javascript" src="https://2h.ae/script.js"></script>

 

Except for domain names:

You can exclude domain names if you wish. You can add an exclude parameter to exclude domain names. The example below shortens all URLs but excludes URLs from google.com or apple.com.

 

<script type="text/javascript"> var key = "2b2614538225c4898e88c66c32238157"; var exclude = ["google.com","apple.com"]; </script>

<script type="text/javascript" src="https://2h.ae/script.js"></script>

 

Restrict domain names:

You can restrict domain names by adding the include parameter to restrict domain names. The example below shortens all URLs within the include domain name.

<script type="text/javascript"> var key = "2b2614538225c4898e88c66c32238157"; var include = ["google.com"]; </script>

<script type="text/javascript" src="https://2h.ae/script.js"></script>

 

 

Keep reading

More posts from our blog

Quick shortening of links August 22, 2024