While it's possible to reroute traffic from your website domain to branded links, we highly recommend using a dedicated custom domain.
With a unique custom domain, you avoid complex CMS or server configuration, reduce potential points of failure, and remove the risk of misconfiguration.
If you don't want a separate domain, Rebrandly's domain alias feature lets you use the same domain for both your website and your branded links.
Incorrect changes could bring your website down. This technical process requires the knowledge and permissions to make changes to your website or CMS.
To set up a domain alias:
Choose the instructions for your technology and product
Add the domain to your Rebrandly account
If you previously connected the domain to Rebrandly using the classic DNS method, please delete the domain and re-add specifying that you want it to be an alias.
Follow the steps to add a domain using these parameters:
After entering the domain name, select No, it's being used for my website, and then select Use domain directly.
Copy the alias domain and keep the page open to reference the information for the following steps. (You can also find it later in the server configuration of the domain's settings.)
If you're using your own scripts or Cloudflare
Custom scripts
We provide guidance and some plugins below, but if you opt for a solution using a custom script, please make sure that the script is activated only for requests currently leading to your 404 (page not found) page. A mistake in the configuration could lead to redirect all your website's traffic to Rebrandly, resulting in downtime for your services.
Cloudflare
When using an alias domain with Cloudflare proxy protection, domain validation may fail with a 403 error. This occurs because Cloudflare's Bot Fight Mode blocks our validation requests.
To complete domain validation while using Cloudflare, you'll need to whitelist our validator IP address. To do this:
Log in to your Cloudflare dashboard
Navigate to Security > WAF > Tools
Create a new rule to allow traffic from our validator's static IP:
52.71.78.8Save the rule and retry domain validation
This whitelist rule only allows our specific validation server through Cloudflare's protection, keeping your site secure while enabling successful domain verification.
WordPress CMS
We have a WordPress plugin available for managed WordPress services (such as WPEngine).
Node.js/Express
We have a Node.js/Express package available.
NGINX Web Server
The following instructions are meant for users with expertise in routing strategies.
To prevent loops from occurring, this script will make your current 404 page invisible. If you still want to show the 404 page for all traffic which does not match a branded link, you should:
Define a new, specific route to reach your 404 HTML page (e.g. /404 or /not-found).
Set this route in the custom domain configuration in Rebrandly as "Custom 404 URL" (e.g. https://mydomain/not-found), so that Rebrandly will call back your website at the specific route without entering a loop.
To set up the alias domain:
Add the following instructions in the configuration file to forward ONLY your 404 traffic to Rebrandly. Replace #{{alias}} , including the brackets, with the alias domain you copied from Rebrandly.
server { ... location / { # define the error function error_page 404 = @rebrandly; } location @rebrandly { rewrite ^/(.*)$ https://#{{your alias domain}}/$1 redirect; }... }Follow these instructions to manually upload a verification file in order to pass the domain verification by Rebrandly.
IIS Web Server
The following instructions are meant for users with expertise in routing strategies.
To prevent loops from occurring, this script will make your current 404 page invisible. If you still want to show the 404 page for all traffic which does not match a branded link, you should:
Define a new, specific route to reach your 404 HTML page (e.g. /404 or /not-found).
Set this route in the custom domain configuration in Rebrandly as "Custom 404 URL" (e.g. https://mydomain/not-found), so that Rebrandly will call back your website at the specific route without entering a loop.
This configuration will work only on a file-based web page. If you have an application installed on ISS, we recommend you install a plugin in the application itself, instead.
To set up the alias domain:
Add the following instructions on the web.config file to forward ONLY your 404 traffic to Rebrandly. Replace #{{alias}} , including the brackets, with the alias domain you copied from Rebrandly.
<rewrite> <rules> <rule name="Imported Rule 1" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> </conditions> <action type="Redirect" redirectType="Found" url="https://#{{alias}}/{R:1}" /> </rule> </rules></rewrite>Follow these instructions to manually upload a verification file in order to pass the domain verification by Rebrandly.
Javascript (client-side)
The following instructions are meant for users with expertise in routing strategies.
To prevent loops from occurring, this script will make your current 404 page invisible. If you still want to show the 404 page for all traffic which does not match a branded link, you should:
Define a new, specific route to reach your 404 HTML page (e.g. /404 or /not-found).
Set this route in the custom domain configuration in Rebrandly as "Custom 404 URL" (e.g. https://mydomain/not-found), so that Rebrandly will call back your website at the specific route without entering a loop.
To set up the alias domain:
Locate your current 404 page.
Locate the <head> section in the HTML: it is important that the Rebrandly script is loaded as early as possible so that no content is shown before the redirection takes place.
Integrate the following code (copy from <script type="text/javascript"> until </script>) right after the opening tag for <head> as in the example. Replace #{{alias}} , including the brackets, with the alias domain you copied from Rebrandly.
<html> <head> <script type="text/javascript"> window.location = "https://#{{alias}}/" + window.location.pathname + window.location.search; </script> … </head> ...</html>Follow these instructions to manually upload a verification file in order to pass the domain verification by Rebrandly.
PHP
The following instructions are meant for users with expertise in routing strategies.
To prevent loops from occurring, this script will make your current 404 page invisible. If you still want to show the 404 page for all traffic which does not match a branded link, you should:
Define a new, specific route to reach your 404 HTML page (e.g. /404 or /not-found).
Set this route in the custom domain configuration in Rebrandly as "Custom 404 URL" (e.g. https://mydomain/not-found), so that Rebrandly will call back your website at the specific route without entering a loop.
To set up the alias domain:
Locate the PHP function currently returning your current 404 page
Integrate the following code as the first code instruction of the function. Replace #{{alias}} , including the brackets, with the alias domain you copied from Rebrandly.
<$ Header( "Location : https://#{{alias}}{$_SERVER["REQUEST_URI"]}" );$>Follow these instructions to manually upload a verification file in order to pass the domain verification by Rebrandly.
.NET core
The following instructions are meant for users with expertise in routing strategies.
To prevent loops from occurring, this script will make your current 404 page invisible. If you still want to show the 404 page for all traffic which does not match a branded link, you should:
Define a new, specific route to reach your 404 HTML page (e.g. /404 or /not-found).
Set this route in the custom domain configuration in Rebrandly as "Custom 404 URL" (e.g. https://mydomain/not-found), so that Rebrandly will call back your website at the specific route without entering a loop.
To set up the alias domain:
Locate the Startup.cs file or any other file currently managing your current 404 behavior.
Integrate the following code. Replace #{{alias}} , including the brackets, with the alias domain you copied from Rebrandly.
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { ... app.Use(async (context, next) => { await next(); if (context.Response.StatusCode == 404) { // redirection rule context.Response.Redirect($"https://{alias}{context.Request.Path}{context.Request.QueryString}"); } }); app.Run(async (context) =>... }}Follow these instructions to manually upload a verification file in order to pass the domain verification by Rebrandly.
Flask
The following instructions are meant for users with expertise in routing strategies.
To prevent loops from occurring, this script will make your current 404 page invisible. If you still want to show the 404 page for all traffic which does not match a branded link, you should:
Define a new, specific route to reach your 404 HTML page (e.g. /404 or /not-found).
Set this route in the custom domain configuration in Rebrandly as "Custom 404 URL" (e.g. https://mydomain/not-found), so that Rebrandly will call back your website at the specific route without entering a loop.
To set up the alias domain:
Locate the Flask function currently returning your current 404 page
Integrate the following code, replacing #{{alias}} , including the brackets, with the alias domain you copied from Rebrandly.
@app.route('/<path:path>') def catch_all(path): new_path = 'https://#{{alias}}/' + path return redirect(new_path, 302)Follow these instructions to manually upload a verification file in order to pass the domain verification by Rebrandly.
Test the integration
Create a branded link in Rebrandly using your alias domain, then open the short link in your browser. If everything is configured correctly, it should redirect to your destination URL.

