# Custom Domains for Short Links

Take advantage of your highly-recognizable brand and increase conversions while saving characters in SMS messages using Airship-shortened links with a custom domain.
You can replace Airship's standard `airsp.co` or `airsp.eu` domains for shortened links with your own **custom short link domain**. To take advantage of a shortened, custom domain, you must:

1. Register your short domain name with a Domain Name Registrar. Your custom short link domain can include a subdomain, but it cannot include a path.

   * **Supported**: `https://my.site.co`
   * **Not Supported**: `https://mysite.co/path`

   The links that you use in your messages can, of course, contain paths.
1. Host your domain. Airship supports custom short link domains using HTTP and HTTPS.

1. Implement a redirect configuration applicable to the web server you use. This document contains instructions for a few common web servers.
   * [nginx server configuration](#nginx)
   * [Apache server configuration](#apache)
   * [Microsoft IIS configuration](#microsoft-iis)
> **Note:** Sample configurations on this page may differ from your actual setup.

1. [Contact Airship Support](https://support.airship.com/) to enable your custom short link domain.

When you send an SMS/MMS message from Airship with link shortening enabled:

* Your end users will receive a shortened link, e.g., `http://mysite.co/abcd1234`.
* Your domain must forward `http://mysite.co/abcd1234` to `https://airsp.co/abcd1234` or `https://airsp.eu/abcd1234` (depending on your Airship data center).
* Airship will handle the final redirect to the full URL that you provided in your original message, e.g., `http://myfullsite.example.com/longURL?query=1234`.

```mermaid
sequenceDiagram
Airship->>Audience: Send SMS with shortened link
Audience ->>Custom Domain: Clicks custom link
Custom Domain ->> Airship: Forwards custom domain to airsp.com or .eu with request_uri
Airship ->> Airship: Resolves short link to original URL
```


## Nginx Server Configuration {#nginx}

Use one of the following configurations to redirect your custom short link domain to Airship. The `request_uri` appended to your custom short link domain — e.g., `https://mysite.co/abcd1234` — passes through to Airship's short link domain — e.g., `https://airsp.co/abcd1234`. Airship then resolves the shortened link, redirecting the user to the original link in your message — e.g., `https://myfullsite.example.com/deals?cart=4321id=0987lkjh`.

**HTTP-only redirect:**

```nginx
server {
    listen 80;
    
    location / {
      return 303 https://airsp.co$request_uri;
    }
}
```


**HTTP and HTTPS redirect:**
 
```nginx
server {
	listen 80;
	    
    location / {
        return 303 https://airsp.co$request_uri;
    }
}

server {
	listen 443 ssl;
	ssl on;
	ssl_certificate 	/etc/nginx/ssl-certs/airsp.crt;
	ssl_certificate	/etc/nginx/ssl-certs/airsp.key;

	location / {
		return 303 https://airsp.co$request_uri;
	}
}
```


## Apache Server Configuration {#apache}

Use one of the following configurations to redirect your custom short link domain to Airship. The `request_uri` appended to your custom short link domain — e.g., `https://mysite.co/abcd1234` — passes through to Airship's short link domain — e.g., `https://airsp.co/abcd1234`. Airship then resolves the shortened link, redirecting the user to the original link in your message — e.g., `https://myfullsite.example.com/deals?cart=4321id=0987lkjh`.

**HTTP-only redirect:**

If the `mod_rewrite` module is enabled, add the following lines to your `sites-available/000-default.conf` file.

```apacheconf
<VirtualHost *:80>
	... other .conf code...
	<Location />
		Redirect 303 https://airsp.co%{REQUEST_URI}
	<Location>
</VirtualHost>
```


**HTTP and HTTPS redirect:**
 
In your `sites-available/default-ssl.conf` file, add a `Location` directive block containing the following:

```apacheconf
<VirtualHost _default_:443>
  ... other .conf code...
  <Location />
      Redirect 303 https://airsp.co%{REQUEST_URI}
  </Location>
</VirtualHost>
```


In your `sites-available/000-default.conf` file add the following two lines. This assumes that the `mod_rewrite` module is enabled for your server.

```apacheconf
<VirtualHost *:80>
	... other .conf code...
	<Location />
		Redirect 303 https://airsp.co%{REQUEST_URI}
	<Location>
</VirtualHost>
```


## Microsoft IIS Configuration {#microsoft-iis}

Use the following configuration to redirect your custom short link domain to Airship. The `request_uri` appended to your custom short link domain — e.g., `https://mysite.co/abcd1234` — passes through to Airship's short link domain — e.g., `https://airsp.co/abcd1234`. Airship then resolves the shortened link, redirecting the user to the original link in your message — e.g., `https://myfullsite.example.com/deals?cart=4321id=0987lkjh`.

1. Click **Default Web Site**.
1. In the *Feature View*, click **URL Rewrite**.
1. In the *Actions* panel, click **Add rules…**.
1. In the *Add Rules* dialog, select **Blank Rule** and click **OK**.
1. When defining the *Rewrite Rule*, set the following:
    * **Requested URL**: `Matches the Pattern`
    * **Using**: `Regular Expressions`
    * **Pattern**: `[^/]*$`, which matches the request URI through the end of the regex string
    * **Ignore Case**: unchecked 
    * **Action Type**: **Redirect**
    * **Redirect URL**: `https://airsp.co/{R:0}` where `{R:0}` specifies the request URI
    * **Append query string**: unchecked
    * **Redirect type**: **See Other (303)**