Build Easy Social Media Shortcut URLs to Your Site with .htaccess

Since Martech Zone is built on WordPress, we utilize the redirections feature in Rank Math to manage all of our referring URLs for our site. We’ve even modified our redirect code to append UTM campaign query strings automatically on any links we use like this.

If you view our social links in our header, you’ll see that these are all internal links that redirect with nofollow. The nice part about this is that I have an easy link to distribute for any of our social media sites. Example: YouTube is https://martech.zone/refer/youtube/

The advantage of this is pretty simple. Social media handles sometimes become available, and you can easily update your handle. If you’re distributing your links rather than your handle, you can always update your redirects for the new social media handle. This means your print material, PDFs, etc., can simply have your easy URL and will never require updating if you modify your handles.

htaccess

The majority of websites online are built on Apache’s web server, which enables you to build redirects using htaccess. It’s a plain text configuration file that’s both powerful and flexible, enabling website administrators to make various configuration changes per directory. In this case, we can update our .htaccess file in the root directory of our site to easily redirect visitors to external sites.

Redirect 301 /linkedin https://www.linkedin.com/company/martechzone/
Redirect 301 /facebook https://facebook.com/marketingtechnology
Redirect 301 /twitter https://twitter.com/martech_zone
Redirect 301 /youtube https://www.youtube.com/@MartechZone
Redirect 301 /rss https://feed.martech.zone/
Redirect 301 /podcast https://interviews.martech.zone/

You can make as many of these as you’d like to handle all of your external links that you’d like to be made into shortcuts. I actually think this is a far better way to create these than distributing shortened URLs.

Apache does log information about requests and responses, including those that involve .htaccess redirects. When a redirection occurs due to rules defined in the .htaccess file, Apache typically logs the request and response status codes, which can help you track and analyze the redirections.

I suppose you could even compile this information into a report if you wanted to see all of the people utilizing your distributed easy URL, but I haven’t done that.

Appreciate this content?

Sign up for our weekly newsletter, which delivers our latest posts every Monday morning.

We don’t spam! Read our privacy policy for more info.

Check your inbox or spam folder to confirm your subscription.

Exit mobile version