_redirect file not working as intended

PLEASE help us help you by writing a good post!

My website is buildstack.co (netlify name - https://buildstack.netlify.app/). I have a page at /community that I’m trying to have served at https://community.buildstack.co.

I’ve added a CNAME ‘community’ in my registrar pointing to my netlify site and added https://community.buildstack.co as a custom domain in Netlify.

I also added a redirect file in my public folder
https://community.buildstack.co/* /community/:splat 200

The build was deployed successfully but when I visit the subdomain, I get a netlify page not found error.

Hi @alwaysaugust, thanks for the post.

Kindly change the contents of your _redirects file to the below

https://community.buildstack.co/* https://www.buildstack.co/community/:splat 200

Let me know the outcome.


It redirects me to https://community.buildstack.co/community and loads a 404

Any ideas about how we should proceed?

Hi @alwaysaugust, thanks for the feeback
Kindly read the documentation below on domain level redirects

Let me know the outcome

Still no luck with this

HI, @alwaysaugust. There is one small change I would suggest and I also want to explain why I’m suggesting it.

The URL the proxy redirect rule is pointing to is this:


What happens when I make a request for that exact URL? This is shown below (the egrep is just a filter so only the headers are shown):

$ curl --compressed -svo /dev/null --stderr - https://www.buildstack.co/community/  | egrep '^(<|>)'
> GET /community/ HTTP/2
> Host: www.buildstack.co
> User-Agent: curl/8.4.0
> Accept: */*
> Accept-Encoding: deflate, gzip
< HTTP/2 308
< age: 0
< cache-control: no-cache
< cache-status: "Netlify Edge"; fwd=miss
< date: Thu, 21 Dec 2023 19:39:14 GMT
< location: /community
< refresh: 0;url=/community
< server: Netlify
< strict-transport-security: max-age=31536000
< x-nf-render-mode: ssr
< x-nf-request-id: 01HJ6Y77YMMW10FDM6BFG50C6K

That is a 308 status response being returned by the Next.js SSR route. It is redirecting to the same URL without the trailing slash. My suggestion here is to do the same and remove the trailing slash in the redirect rule like so:

https://community.buildstack.co/* https://www.buildstack.co/community 200!

Note, the splat rule is missing so subpages should need additional rules. That said, I don’t see any subpages so you might be fine with just that single rule above. Would you be willing to give it a try and let us know the results?

1 Like

I tried it and it’s at least loading, but the styling is broken now https://community.buildstack.co/

It looks like the _redirects is hijacking all the calls, including those trying to get styles, and directing them to /community instead of the root or src. I tried this:

/_next/static/*  /_next/static/:splat  200
/static/*  /static/:splat  200
https://community.buildstack.co/*  https://www.buildstack.co/community  200!

And that didn’t change naything

Hi, @alwaysaugust. There is a typo in my reply and I’m sorry about that. Would you please just this one redirect instead (without the “static” rules):

https://community.buildstack.co/  https://www.buildstack.co/community 200!

I deleted the “*” above from the rule below:

https://community.buildstack.co/* https://www.buildstack.co/community 200!

With the top rule, this should be resolved.