How to return fixed response for a sub domain

Our system has more than 1000 sites, each site has a few sub domain. How can I return fixed response 404 for deleted sub domains.
For example, we have 2 sub domains, namely trial.example.com, pro.example.com in zone example.com. I want to get 404 fixed response when accessing trial.example.com.
After some searching, I knew that using fixed response in LB may made it possible. But our system have many sites, so creating a new LB for each site is very costly

Iā€™m not sure how a deleted subdomain would return a 404. It should receive a NX Domain error due to the lack of a DNS record.

But if you want to remove the content of a subdomain, you could create a Worker that contains your 404 page. Then make a route for that subdomain that points to the 404 worker.

I has found a way to make it possible. Just update the cname record of trial.example.com to a load balancer which returns a 404 fixed response by default

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.