简体   繁体   中英

Redirect one domain to another if first domain wasn't visited

I have two apps on Heroku. I ONLY want people to access the second app, if they have already visited the first app. Meaning if you went directly to app2.herokuapp.com it would redirect you to app1.herokuapp.com. But if you came from app1.herokuapp.com then it would NOT redirect when you got to app2.herokuapp.com

One more thing, I am only looking to redirect people that get to the naked URL. FI they go to an internal page, I don't want it to redirect.

Is there a way to do this directly in heroku? If not what is the best way to do this?

The easiest way would be to use cookie/session and from your applications handle the logic.

Just in case also some CDN's allow custom rules based on cookies so this could be useful for a serverless setup, based on the site the user visit you set a cookie and once the "rule/condition" decides where to redirect the requests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM