How to redirect a path content to subdomain?

Hi everyone, I need help to do redirecting path content to subdomain. To help you to understand, for example that my domain is https://www.example.com/ and my website content is available in the domain path https://example.com/blog. I want to make my website content available at https://blog.example.com .

How to do this on netlify?

hi @afnizarnur - did you read through this already?

Also, if you search the forums, you will find a variety of different posts addressing this issue.

Let us know if you can’t make it work for some reason :muscle:

Thank you for your reply!

Yes, I already read the docs and some of the posts in this forums.
But can’t find what I’m looking for.

Right now, here the netlify.toml that I create based on what I read. Also, I already add CNAME record for my subdomain on netlify domain panel.

[[redirects]]
from = “/blog/*”
to = “https://blog.example.com/:splat
status = 200
force = true

But when I access the https://blog.example.com/ show up This site can’t be reached.

I also replied about this here but using the _redirects file format below:

https://blog.example.com/* https://example.com/blog/:splat 200

In netlify.toml format this would be:

[[redirects]]
  from = “https://blog.example.com/*”
  to = “https://example.com/blog/:splat”
  status = 200

There was a force = true in your example and not in mine. Including this may be better depending on the use case so please do include it if you prefer:

[[redirects]]
  from = “https://blog.example.com/*”
  to = “https://example.com/blog/:splat”
  status = 200
  force = true

This would match the _redirect rule with a 200! like so:

https://blog.example.com/* https://example.com/blog/:splat 200!

Please let us know if this doesn’t work as expected or if there are other questions.

1 Like

Thanks for your help!!

1 Like