Domain Alias Configuration Options

In order to use a NON-spare domain name to create branded links with Rebrandly, while simultaneously using that domain for your website, first you need to connect it to your Rebrandly account. Then you to activate the 404 redirect to the alias. While the instructions to connect the domain are available with this article, the activation part requires some actions from your side. 

Please note that the following methods are alternatives. You can choose any one of them based on your domain name configuration as well on your expertise with the method/coding-language/etc... 
These configurations are only needed once, just for the first setup of the domain alias.

  • Please note that these configurations may not be that simple so we strongly advise requesting the help of someone with expertise around domain names and server configurations.
  • Please be sure to forward to Rebrandly only 404 (page not found) traffic, a wrong integration could lead to redirect all your website's traffic to Rebrandly.
  • If you have any doubts do not hesitate to ask for help from our support: Rebrandly.support/contact

After a NON-spare domain name is associated (connected) to your Rebrandly account you will need to update the 404 (page-not-found) traffic routing. This setup can only be made from your side. Basically, you will have to route all the 404 traffic from your website to a specific domain name provided by Rebrandly (the alias). 

In the following, the alias domain is the alternative domain provided by Rebrandly. 

The following methods are alternatives - you will only have to choose one. The alias domain on Rebrandly will only work after the configuration is done and saved from your side. The domain alias details and instructions will also appear in the list of your domain names. You will receive an email when it is ready to be used. 

 

WordPress CMS

In case your website/blog is on WordPress there are many plugins available for traffic redirect. You will need to install one of them (for example: https://wordpress.org/plugins/redirection) and be sure to redirect all the 404 (page-not-found) traffic to the alias domain name. 
Important: In order to allow the domain verification by Rebrandly you also need to follow these instructions to upload the verification file.

 

Apache Web Server/ HTACCESS

Add the following instructions on the .htaccess file to forward your 404 traffic to Rebrandly.

Please note that the configuration will work only on a file based web page, if you have an application look at code example

 # make sure rewrite engine is enabled

RewriteEngine On 

# add these lines at the end of the file

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ https://{{alias}}/$1 [R,L]

 

NGINX Web Server

Add the following instructions in the configuration file forward your 404 traffic to Rebrandly

server { 
...
location / {
# define the error function
error_page 404 = @rebrandly;
}

location @rebrandly {
rewrite ^/(.*)$ https://{{alias}}/$1 redirect;
}
...
}

 

IIS Web Server

Add the following instructions on the web.config file to forward your 404 traffic to Rebrandly.
Please note that the configuration will work only on a file based web page, if you have an application look at code example.

<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>


Javascript Code

A) Add the following code when you load the 404 page to forward your 404 traffic to Rebrandly.
B) In order to allow the domain verification by Rebrandly you also need to follow these instructions to upload the verification file.

<html>
<head>
<script type=”text/javascript”>
window.location = "https://{{alias}}/" + window.location.pathname + window.location.search;
</script>
…. </head>
…. </html>

 

PHP Code

A) Add the following code in the header of the file when you load the 404 page to forward your 404 traffic to Rebrandly.
B) In order to allow the domain verification by Rebrandly you also need to follow these instructions to upload the verification file.

<$ 
Header( "Location : https://{{alias}}{$_SERVER["REQUEST_URI"]}" );

$>

 

Node.js Express Code

Add the following function to forward your 404 traffic to Rebrandly.

app.use(function(req, res, next){
res.redirect(302, ‘https://{{alias}}’ + req.originalUrl)
})

 

.Net Core code

Add the following instructions in the Startup.cs file to forward your 404 traffic to 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) =>...
}
}

 

Flask Code

Add the following function to forward your 404 traffic to Rebrandly

@app.route('/<path:path>') 
def catch_all(path):
new_path = 'https://{{alias}}/' + path
return redirect(new_path, 302)

 

TIP: If the configuration method you need/prefer is missing please let us know and we will add it. 

 

This article is about:

  • Domain alias for branded links
  • 404 traffic redirect options for branded domain names
  • Use the main domain for branded links
  • Use a domain name for the company website and branded links
  • Your brand on your links - alias domain name
  • Url shortener with the main domain name

See also:

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.