const destinationURL = "https://example.com"const statusCode = 301
async function handleRequest(request) { return Response.redirect(destinationURL, statusCode)}
addEventListener("fetch", async event => { event.respondWith(handleRequest(event.request))})
server {
listen 80;
listen 443 ssl;
server_name www.old-name.com;
return 301 $scheme://www.new-name.com$request_uri;
}
https://hostloc.com/forum.php?mod=redirect&goto=findpost&ptid=837904&pid=10293928