Register subdomain on netlify

hi @berni,

our docs have a lot of the information you will need to get started:

if you use the search for this site, you will also see that we have answered a lot of subdomain related questions, it is very likely that any questions you might have are already answered :slight_smile:

What should I search the site for? :wink:

Would I need to have a sub domain provided by webhost which I could transfer the DNS to netlify?

Or is there a way to create a subdomain on my custom domain name?

:thinking:

hey berni,

You can use the search on this community forum for anything you would like. If you are setting up a subdomain for your site, you can use the search as follows after reading the docs to see solutions for previous posts.

https://answers.netlify.com/search?expanded=true&q=subdomain

If you read through the docs link i previously provided, you can learn how to set up subdomains on domains that you already own, yes.

I’m having some difficulty with the terminology used in that doc you sent me.

Is it custom domains? :face_with_raised_eyebrow:

Hi,

I’ve read through the documentation and worked it out.
There was some information that came up in my dashboard about a CNAME entry on my DNS provider. I didn’t manage to note the information and it won’t display again.

Can anyone help? :wink:

Hi, @berni, do you want to change the subdomain used at Netlify for the site? If so, this is done by going to “Site Name” > Settings > General > Site details and then click the “Change site name” button.

Now, if you want to point custom domains to a Netlify site, they are first added to the site under “Site Name” > Settings > Domain management > Custom domains.

The DNS configuration for the custom domain must also be correct. Please use these instructions below if you do not use Netlify DNS:

Or these instructions if you do use Netlify DNS:

If there are questions about any of this, please let us know.

:grinning:

I have a domain alias setup: www.vendors.my-domain.com and i want to redirect it to: https://my-domain-vendors.com

Setting 200 in the TOML rule sets it to a rewrite. Keeping the URL the same in the browser which is what I want.

[[redirects]]
from = “https://www.vendors.my-domain.com
to = “https://my-domain-vendors.com
status = 200

But the content isn’t loaded into my SPA.

Setting 301 in the TOML rule to a redirect. Which changes the URL in the browser. Which is not what I want to happen.

[[redirects]]
from = “https://www.vendors.my-domain.com
to = “https://my-domain-vendors.com
status = 301

How can I keep the as https://www.vendors.my-domain.com and see the content of the webpage at https://my-domain-vendors.com ?

Can anyone help? :nerd_face:

Hi, @berni, the first rule should work in most cases.

It if isn’t working, it would be helpful to examine the actual site at Netlify to find out why. What is the URL which should be working and isn’t? I ask because the domain www.vendors.my-domain.com isn’t hosted at our service and I need to know the actual URL to answer.

Hi @luke ,

The domains are listed below…

From

  • www.vendors.wherecanibuyit.online
  • vendors.wherecanibuyit.online

To

I set up a redirect (301) rule which is redirecting and working online. But I want the rule to work as a rewrite (200).

Could you link us to a deploy in your deploy history where you had it in place as a 200? redirects are deploy-specific, so we can perhaps find it if you link us to the logs page for that build, to look at what you had written.

Hi @luke and @fool,

The deploy link is: https://app.netlify.com/sites/wherecanibuyitonline/deploys/5e54e2b343e50d0008b382a6

Thanks,
Bernard

Hi, @berni. The issue here is that this URL is valid for that deploy:

https://vendors.wherecanibuyit.online/

The rule doesn’t have a “force” option so it will not proxy for content which does exist. If you want the 200 rule to always proxy, even for content which exists at the current site, then force the proxy like so:

[[redirects]]
  from = "https://www.vendors.wherecanibuyit.online/*"
  to = "https://www.wherecanibuyitonline.me/:splat"
  status = 200
  force = true

[[redirects]]
  from = "https://vendors.wherecanibuyit.online/*"
  to = "https://www.wherecanibuyitonline.me/:splat"
  status = 200
  force = true

Note, I also added a “splat” rule to keep the path when proxying. Would you please test the two rules above and let us know if they work as required?

@luke I’ll do that and get back to you.

@luke when i enter https://vendors.wherecanibuyit.online in my web browser address bar, I see this.

And not the content of the web page at this address: https://www.wherecanibuyitonline.me which is this:

The rewrite rules are:

[[redirects]]
from = “https://www.vendors.wherecanibuyit.online/*”
to = “https://www.wherecanibuyitonline.me/:splat
status = 200
force = true

[[redirects]]
from = “https://vendors.wherecanibuyit.online/*”
to = “https://www.wherecanibuyitonline.me:splat”
status = 200
force = true

Seems to do the right thing to me:

  1. browse to https://www.vendors.wherecanibuyit.online
  2. browser fetches and displays https://www.wherecanibuyitonline.me (content starts with <!doctype html><html lang="en"><head><meta name="title" content="Where Can I Buy It Online - Vendor Dashboard"/>)

Perhaps your blank page was related to something else - I see what you demonstrated, except, at the original URL as shown in this screenshot:

Hi @fool,

Thanks for the response. The www rewrite works. Can we achieve the same result for https://vendors.wherecanibuyit.online?

Thanks for looking into this.

Regards,
Bernie

Hi, @berni, the rule in netlify.toml is this:

[[redirects]]
  from = "https://vendors.wherecanibuyit.online/*"
  to = "https://www.wherecanibuyitonline.me:splat"
  status = 200
  force = true

There is a missing “/” on the “to” line right before “:splat”. It should be this instead:

[[redirects]]
  from = "https://vendors.wherecanibuyit.online/*"
  to = "https://www.wherecanibuyitonline.me/:splat"
  status = 200
  force = true

Would you please let us know if that change resolves the issue?

@fool thanks for your reply.

It has resolved the issue. However the second rewrite speed is much slower than the first. Is it possible to make the speed of the second rewrite the same speed as the first?

Regards,
Bernie

Our caching is opportunistic; we don’t pre-cache things like that rewrite, we cache it as it is first requested. I suspect that you’ll see faster performance on subsequent loads from the same CDN node.

I see 3 slow loads, and 32 fast loads over the past 7 days on that URL.