I recently helped a client setup a custom domain for their bitly account. Bitly of course makes this extremely easy except for one small thing: We wanted the root domain to redirect to their main site.

To give an example, let’s say I had a custom short domain of “amit.st” that I wanted to use for redirecting people to “amitstreet.com”. The standard approach is to point the A-Record of that domain to Bitly’s IP address. And for any shared link, this will redirect fine, but if someone gets curious and wants to type in just “http://amit.st” they’ll get redirected over to “http://bit.ly” which is not what I want.

So after a quick Google search, I found the answer, and I’ll share it here:

First: Point your DNS at your own server (i.e. do NOT point your A-Record at Bitly’s IP Address)

3) In Line 4 of the .htaccess code, replace the “xUniVT” with whatever bitly generates for the hompepage redirect you made in step 2

4) Line 5 is a little bonus: Instead of giving people “amit.st/4rReses” (which is bitly’s autogenerated URLification), you can make your own human-understandable shortness (i.e. amit.st/cool) and replace the “custom” with “cool” (remember, see line 5), and replace the “yX3Lbm” with whatever bitly autogenerates for you.

This entry has 2 comments

Looks good, though am I right in saying that you can’t use bit.ly’s custom domain feature as you’re not pointing the domain to them?

It’s great to redirect the root domain, but then you can’t use their actual services.

On June 25, 2013

Amit Savyon wrote:

Well, I’m saying that their custom domain feature doesn’t (or didn’t, when I wrote this post) allow you to map just the root domain to redirect to your main site. That’s the whole issue I got around with this method described here