Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lasota's avatar
Level 10

www prefix on subdomain

Is there a good way in the forge interface to manage a redirect from www.subdomain.domain.com to subdomain.domain.com?

0 likes
3 replies
aurawindsurfing's avatar

Hey @lasota

You could use build in forge redirects but this is not the correct way to handle this.

You should use your DNS records to do this. I use Cloudflare for it and it should look like this:

CNAME record for www.subdomain pointing to subdomain.domain.com

A record for subdomain.domain.com pointing to your forge IP.

Hope it helps!

PS. I'm not too sure about this part: www.subdomain or fullwww.subdomain.domain.com for CNAME, it works just for www for TLD

fylzero's avatar

@lasota You could probably add a Redirect Rule in Forge. Alternately this could be done in the .htaccess file in the public directory of your project or possibly via a redirect in a Laravel route or middleware or something.

1 like
lasota's avatar
Level 10

Thank you all, I guess I was more wondering if there was an easy way to manage this through forge and not really mess with config files directly. But I went with doing it through the mentioned dns zone file and not let the server have to worry about directing traffic with an extra unnecessary call.

Please or to participate in this conversation.