Recomendation
Since Cloudflare provides a free plan and automatically handles certificates and redirections, it is a preferred configuration method. Check Cloudflare guide.
To configure your custom domain as a tracking domain for instasent, you just need to set up a 302 temporary redirection from yourdomain.com/* to inst.to/yourdomain.com/* in both HTTP & HTTPS protocols. By doing that, any access to yourdomain.com/any-link will be automatically redirected to our inst.to server (our shortener service) and we will take care of it automatically.
Web server configuration
*You need access to the web server configuration files (NGINX / APACHE) for that domain
*You have both HTTP & HTTPS properly configured for that domain with a valid SSL certificate.
*These are minimal instructions, the steps may require adaptations depending on your web server versions and configuration.
1. For Nginx
Open your Nginx configuration file. This is typically located at
/etc/nginx/nginx.conf
or/etc/nginx/sites-available/yourdomain.com
.Inside the
server
block, add the following lines:
server { server_name yourdomain.com; location / { return 302 <https://inst.to/yourdomain.com$request_uri>; } } [Do the same for the HTTPS version]
Save the file and test the configuration with
nginx -t
.Reload Nginx to apply the changes:
sudo systemctl reload nginx
.
2. For Apache
Open your Apache configuration file for the domain. This might be located at
/etc/apache2/sites-available/yourdomain.com.conf
or a similar directory.Ensure that the
mod_rewrite
module is enabled. You can enable it withsudo a2enmod rewrite
and then restart Apache.Inside the
<VirtualHost>
block for your domain, add the following lines:
<VirtualHost *:80> ServerName yourdomain.com RewriteEngine On RewriteRule ^/(.*)$ <https://inst.to/yourdomain.com/$1> [R=302,L] </VirtualHost> [Do the same for the HTTPS version]
Save the file and restart Apache to apply the changes: sudo systemctl restart apache2.
Check redirection
Once your configuration is applied any access to yourdomain.com should be redirected automatically to our service, you can check it by trying it in your browser.
In both cases, you should end in the instasent.com page automatically. If it works, you can go to Instasent and validate your domains, they will check the redirection and activate the tracking domains if the configuration is correct.
You can use the curl
command to check the location header of the response:
$ curl -I <https://yourdomain.com/test> HTTP/2 302 date: Wed, 03 Jan 2024 10:06:54 GMT location: **<https://inst.to/yourdomain.com/test**> cache-control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0 expires: Thu, 01 Jan 1970 00:00:01 GMT server: your-server