Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect www to root (@)?

Tags:

vercel

How do I setup an alias so that www.mydomain.com permanently redirects to mydomain.com using Zeit now CLI?

I tried now dns add mydomain.com www CNAME mydomain.com but it does not work.

It seems * CNAME alias.zeit.co is prioritized over www CNAME.

like image 611
Joon Avatar asked Nov 22 '25 17:11

Joon


1 Answers

First, you need to add an alias pointing your deployment to your root domain.

now alias my-deployment-url.now.sh example.com

Then you need to add a redirect. Since this is not possible with DNS, you need to have some web server emit a 301/302 redirect. In this case, we'll make a new deployment.

now -e REDIRECT_URL=https://example.com now-examples/redirect

Now that we have this new "redirect" deployment, we'll alias it as www like so:

now alias https://redirect-otytioldup.now.sh www.example.com

See the docs for more info.

like image 87
styfle Avatar answered Nov 24 '25 21:11

styfle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!