Redirect domains to your staging environment

in Nginx configuration

If you are working on a staging environment that contains domains that are not configured on the production shop, you can easily redirect those domains to staging rather than serving the default storefront.

To do this, first create a /data/web/nginx/http.staging_redir_mapping file containing:

map $http_host $staging_site {
  hostnames;
    default 0;
    test.example.nl 1;
}

Next, create a snippet to redirect all sites mapped as staging_site to the staging environment.
To do this, create a /data/web/nginx/server.staging_redir file containing:

if ($staging_site = 1) {
  return 301 http://$http_host:8888$request_uri;
}

Now all traffic for domains that are mapped as staging_domain, will redirect to the same url but on port 8888.

0