vdanchenkov/now-redirect

Problem setting-up

Opened this issue · 6 comments

Hello, there must something I do not understand because I can not get this to work.
I would like to redirect all traffic from mydomain.com to www.mydomain.com.

So I go to my app folder and type
now-redirect www.mydomain.com

It deploys MY app on https://mydomain-gfhsgtwezq.now.sh
But it says:
Requests to https://mydomain-gfhsgtwezq.now.sh/* will be redirected to http://www.mydomain.com/*
and this is not the case! There is no redirect.

I think the problem is that Instead of deploying your small nodejs file that does the redirect, it is deploying my app (which is current folder). I am using now@8.2.3 and it seems that it is ignoring the custom path :/

Am I doing something wrong ?

Only solution I have now is deploying my app and then aliasing it to both domain:
now alias https://mydomain-gfhsgtwezq.now.sh mydomain.com
now alias https://mydomain-gfhsgtwezq.now.sh www.mydomain.com
which is working.

i would also want to know.
My goal is the same but why it creates a new alias ?

i would recommend not running this app from within an existing now deployment directory, as i'm not sure but the results would seem not well-defined.

@transitive-bullshit thanks. So should we fiddle with records in now cli to get the forward working or there exists some command like this?
now-redirect mydomain.com www.mydomain.com

you'll have to run now-redirect and then run now alias like in the readme. the first one sets up a new dummy deployment that just redirects traffic. the second step, now alias makes it so traffic going to your redirected domain goes to the deployment you just setup.

(from readme)

# Generate & deploy app that redirects all inbound requests to www.example.com
now-redirect www.example.com

# Alias deploymentUrl from the previous command to the URL that needs redirected
now alias [deploymentUrl] example.com

# Congrats! Requests to example.com will be redirected to www.example.com

@flieks @pierregoutheraud see #5 as I believe this is why you're having trouble getting now-redirect to work.

thanks
so this is just skipping one step. so now redirect does:

  • deploy to a zeit link
  • alias that zeit link to your domain ?

it's probably better for us to redirect the domain with a domain record..