Forwarding subdomain to a path

Hi, I have created a new site at brhn.me hosted at netlify. Now I want to configure subdomain “bn.mydomain” in a way that internally it will load all contents from a subpath of main site.

“bn.mydomain/sample-post-in-bangla-language” would actually load “mydomain/bangla/sample-post-in-bangla-language”. URL will be shown as “bn.mydomain/sample-post-in-bangla-language” (Not a 302 redirect)

I am just wondering if this is possible in netlify. I did this with wordpress not sure how to do it here.

This challenge involves two part
First is to configure “bn.mydomain” to be forwarded to “mydomain”. Second part is rewriting url “bn.mydomain/*” as “mydomain/bangla/splat”

Is is possible here. If anyone has done similar, please let me know

Howdy!

Should be possible using this workflow:

  1. deploy the content on your main site under the /bangla/ path. This means you’ll deploy your usual content PLUS the content for /bangla/

  2. create a proxy redirect rule for that hostname. This article about how to set up your site for this kind of operation may be useful as you plan/design the layout, even if you don’t use multiple sites or repositories: [Common Issue] Can I deploy multiple repositories in a single site? . Deploy this rule in advance! Here’s a sample that should work for your fake example hostnames:

https://bn.mydomain/* /bangla/:splat 200!

This will leave the browser pointing at the original URL rather than the rewritten one. Since you use one site, you don’t have to actually proxy to a second one (though you could as the article I linked in #1 showed), so your “rewrite” will just be to the local path, and will only be activated for requests to the subdomain.

  1. point the DNS for that hostname to us (to the existing site): https://www.netlify.com/docs/custom-domains/#manual-no-www

  2. put subdomain in place on your site’s Domain Settings page as a domain alias (https://www.netlify.com/docs/custom-domains/#domain-aliases - aka “additional hostname for site”)

  3. await SSL certificate update for that new hostname

  4. ???

  5. profit!

1 Like