Google Apps Custom URL for Secondary Domain

Google Apps only allows custom URLs for primary domains. For secondary domains, you are stuck with the default service addresses provided by Google. But, there’s a workaround.

How Google Apps Custom URLs Work

If you have configured to use a custom URL for Gmail on Google Apps, you will be using an URL similar to http://mail.digitalinternals.com. If we make a HTTP request to that custom URL, we get a HTTP 302 redirect to https://mail.google.com/a/digitalinternals.com. We can verify this using the curl utility.

The custom URLs for other apps like Google Drive, Calendar and Sites get redirected in a similar fashion.

If you notice, the redirects are to the default service addresses provided by Google.

Workaround to Enable Google Apps Custom URL for Secondary Domains

So, if you need a custom URL for a secondary domain hosted on Google Apps, you will need to replicate the HTTP 302 redirects. There are a couple of way to accomplish this. For this workaround, we will only concentrate on the custom URL for Gmail since the concept is the same for the other services hosted on Google Apps.

The first (and the easiest) method is to use the the URL redirect feature provided by certain DNS service providers like Namecheap. This feature is not always available and will depend on your DNS or hosting service provider. Below is a screenshot of the URL redirect configuration using Namecheap.

namecheap url redirect

If your DNS provider does not provide the URL redirect feature, you will need to create a sub-domain on your web host, and add rewrite rules on your web server. So, let’s say that you want to redirect http://mail.secondary-domain.com to https://mail.google.com/a/secondary-domain.com.

On Nginx, you will need the following server block with a rewrite rule.

On Apache, you will need the following VirtualHost block.

This method can also be used to map custom URLs for other services on Google Apps, such as Google Drive or Google Calendar.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }