Configure Subdomain with Heroku and Google domains? - node.js

I want to configure a subdomain on my main website. For example, www.something.com and something.com redirect to the same main website.
I want to add hi.something.com and for this, I used on my nodejs application vhost.
var vhost = require('vhost');
app.use(vhost('hi.something.com', require('./routes/hiIndex')));
//In (./routes/hiIndex) theres just an app.get telling it which page to render when it reaches this URL
When testing it locally, it works, but once I deploy my application to heroku and try to access hi.something.com it doesnt work, it redirect me to the main website, meaning something.com
Do I need to add some extra configuration, perhaps on the DNS settings for google domains or on Heroku?
If so, do I just point it to something.com ??
I have worked with redirect to other websites in form of subdomains but this is my first time trying to make it work from my own application.

You might have a subdomain catch-all redirect which prevents vhost in Node.js from picking up the subdomain. Try adding an A type record in your DNS settings that points to your Herokus server.

Related

Point client domain to our subdomain

We are currently developing a CMS for our clients. We would like to host all their pages on our server like this:
https://www.example.com/client1website or https://www.example.com/client2website.
Is there a simple way to redirect content from https://www.example.com/client1website to https://www.theirdomain.com?
I know that Heroku or Wix work in a similar way, but I don't really know how to achieve it. Setting the CNAME for www to https://www.exmaple.com/client2website is probably not enough?
Godaddy can do https://www.client1website.example.com to https://www.theirdomain.com
But otherwise they are going to need to stop at your server first since you are pointing them down into your directory
You can redirect using status code 308

React, Node.js, Express, Heroku, GoDaddy redirect problem

So I've built an online platform with React using Node.js and Express for the backend. Everything runs as it should on local and on my Heroku URL. Now I want to add a custom domain using GoDaddy, but it is just not working.
I've got my SSL certificate with Heroku and everything there seems to be correct. However, on the GoDaddy side, everything seems to be correct too. I've set my www CNAME in GoDaddy to my Heroku DNS URL. Also, I redirect my root domain to my www.domain and that seems to work fine too. But when I check my www.domain.com it says the location is domain.com which is not correct I guess.
The root domain is studoo.app
the studoo.app request location is set to https://www.studoo.app which is right because I've set that 301 redirect in GoDaddy
But when I go to www.studoo.app the location is set to studoo.app which I don't understand
when visiting www.studoo.app I get the "Your connection is not private" error.
If anyone could help me out, please reach out. I've been searching for a week now 🤦🏻‍♂️
Make sure you have both studoo.app and www.studoo.app as domains on heroku. On go daddy I would point both the root and www to the heroku URL

Can I use subdomains with my Heroku subdomain?

I have a node app which uses vhost to manage subdomains. So, on my localhost I have:
main.localhost
admin.localhost
api.localhost
In production I have:
main.example.com
admin.example.com
api.example.com
I have a staging system on Heroku too.
so what I want to be able to do is:
main.example.herokuapp.com
admin.example.herokuapp.com
api.example.herokuapp.com
That doesn't seem to work. Is there a way of achieving it, or do I need to create a separate domain and point my nameservers there?
Sure this is possible. But you'll need to do this via your main domain, since it appears Heroku doesn't support wildcard subdomains on the herokuapp.com domain. (How to create a subsubdomain for an app on heroku: (e.g. sub.myapp.herokuapp.com))
First, set a CNAME record for *.staging.example.com to point to example.herokuapp.com
Then tell Heroku to route your domain properly:
$ heroku domains:add *.staging.example.com

Cakephp .htaccess : multiple domains pointing to one app

I am working on one cakePHP application.
Now i want to configure my main domain (www.example.com) to be accesses via 'www.xyz.com' or 'www.bcd.com'.
For this i will add the CName record in the 'www.xyz.com' or 'www.bcd.com' as 'www.example.com' then xys.com & bcd.com will point to the example.com.
But now on the xyz.com & bcd.com i can see the content of example.com, but whenever i click on any link it gives me 'URL NOT FOUND' Error.
So i tried lots of .htaccess rules but it is not working.
It is similar to the bloggers custom domain pointing. I need the same thing to be applied for my application.
Can anybody tried this before?
This isn't entirely an .htaccess issue - you need to first edit the server name in your web servers configuration file to serve not only example.com, but also requests coming in from xyz.com and bcd.com.

.htaccess + subdomain + redirect

Just wanted to know how we can redirect the subdomain to domain.
I have two domain which in pointing to my rails application and a subdomain
www.xyz.com
www.xyz.info
example.xyz.com
Now when the user access www.xyz.info the example.xyz.com page should open up but the address bar should be www.xyz.info.
So is it possible to redirect?
Thanks
Abhi
One approach should be to use a reverse proxy, using mod_proxy. In the configuration of www.xyz.info put
ProxyPass / http://example.xyz.com/
However, I think it would be much easier to just deploy the rails application twice, i.e. put the configuration that you have in example.xyz.com also into www.xyz.com.

Resources