Subdomain rewrite to other domain

Hi,

I’m unable to configure subdomain subdomain.maindomain.com to rewrite to www.anotherdomain.com/path/to/page, is the path/to/page a problem or what is it?

In the Netlify DNS I’ve added a CNAME called subdomain with value www.anotherdomain.com/path/to/page but it doesn’t seem to work?

Gr,

Andy

You can’t include a path in a CNAME. A CNAME is only for domain (and subdomain) names.

You could, however, have a Netlify _redirects file on your subdomain.maindomain.com (and a placeholder index.html, perhaps) as a manually deployed site and do a 301 redirect.

Thanks that explains @danielfdickinson1, that was my backup solution indeed but I tried a “cleaner” way using the Netlify DNS. I didn’t know a path wasn’t possible.

1 Like

Hmm I’m unable to get it to work this way. It works on the netlify.app domain but not on the custom domain and the configuration is correct. I have more subdomains working like this with a branch deploy but this is the only one with a _redirects file and that one doesn’t work as expected.

It just can’t find the website. And yes, it has an index.html file.

my _redirects file:

/* https://www.domain.com/rest/of/path 301!

Alright it seemed to be a caching problem.

1 Like