Is there a way to way to control which CNAME gets what content? - express

My ultimate goal is to have free plan cname content, and premium plan cname content.
For example if someone has a cname of free.example.com set to my website I'd like to show them a specific page, and if premium.example.com I want to show them another page. Finally, I'd like to know if there is a way to add new cnames to my list so that I can have them view a certain page?
Just to make this more understandable this, I want to do something like https://www.gitbook.com/ do with their cnames, and cname serving.

You'll have to use the Host header from the user's request to identify which subdomain or cname they're visiting, and then showing them the desired content. If the subdomain such as free and premium are fixed, you could use Nginx server blocks or Apache virtual hosts to direct the user to specific application or application URI.
Likewise, you can get the Host header with req.hostname in Express. Based on the host, you can route the user to the desired content. You can add as much subdomains or cnames you wish and let your application control the content for the user based on the host. If your DNS host has an API (such as Cloudflare), you can add your subdomains programmatically, or you could do a wildcard subdomain to accept any subdomain.

Related

Host custom website on Shopify domain name

My client has a Domain name that he bought from Shopify, is it possible for me to host the website I for him on that domain name ? or do I need to transfer that domain name to a different registrar and then use it ?
Helo there, please provide us more detail, like what is the domain name, what kind of website would you like to host, ect.
If you have a Custom Domain, you will need to transfer it out of Shopify in order to change its nameservers. I recommend transferring it to Namecheap for their cheap prices and amazing customer service. If you don't need to change nameservers for the new host (So you only need to change/add "A" "TXT" "AAAA" "SRV" and/or "CNAME" records), you have the option to keep it in Shopify or to transfer it elsewhere.
More information about DNS on Shopify custom domains: help.shopify.com/en/manual/online-store/domains/managing-domains/advanced-settings

Pointing GoDaddy DNS to GitHub page uses http over https

I have my DNS settings as shown in the image
DNS Setting along with an additional CNAME with host www and value as my GitHub page. Next I setup a CNAME entry in my GitHub page with an apex entry to my domain. The issue I face is that whenever I visit my domain with an https protocol, it shows a warning that the connection is not secure. I get the following in Chrome:
NET::ERR_CERT_COMMON_NAME_INVALID
How do I fix this? I have both https and http access for my domain.
UPDATE: Github introduced custom domain support for HTTPS on May 1, 2018.
If you are using GoDaddy and want to upgrade to HTTPS, do the following:
Go to DNS settings for your site in your GoDaddy account.
Remove all existing A records.
Open a terminal and do dig +noall +answer <YOUR-USERNAME>.github.io. You should see a table listing 4 slightly different IP addresses:
On GoDaddy, create 4 new A records, each one pointing to one of the IPs. For host use # and set the TTL to a low user-defined value (if you are in a hurry).
Go to your page repository settings on Github, and clear the custom domain name and save. Wait a while (minutes).
When executing dig +noall +answer <YOUR-CUSTOM-DOMAIN> yields the 4 IP addresses that you entered in the A records, go back to the Github repository settings and re-enter and save your custom domain name (which you just cleared) in the custom domain cell.
Optionally, check the box Enforce HTTPS. But make sure that https://<YOUR-DOMAIN>is responsive first.
Make sure you have a CNAME record in your DNS settings also. Host should be www and it should point to your <YOUR-USERNAME>.github.io.
Make sure there is a file in your website repository named CNAME containing the name of your custom domain (in my case ulfaslak.com).
Reference
EDIT: Please see answer below by Arturo Herrero: https://stackoverflow.com/a/50203412/462015
GitHub pages does not support HTTPS for custom domains.
The only work around for doing so is to use an SSL provider as the middle man, such as Cloudflare. However, this would involve pointing your DNS name servers at Cloudflare's, which takes some time and complicates things.
If you want HTTPS support using GitHub pages you'll have to use GitHub's provided URL instead of your custom domain.
Another great option for static sites if you want custom domain name HTTPS is Amazon Web Services. You could set up an S3 bucket for your static website, configure CloudFront to distribute the static content, point your domain name at the CloudFront distribution, and use a free SSL certificate from Amazon's cert manager. This option comes out to less than $1/Month with a low-traffic website. A great in depth tutorial for that would be here.
I hope this answered your question! GitHub pages is a great hosting option, and it's not the end of the world if you decide to forget about HTTPS.
Custom domains on GitHub Pages gain support for HTTPS since May 01, 2018
https://blog.github.com/2018-05-01-github-pages-custom-domains-https/

How to point one domain into another existing domain hosting?

I want to point one domain to another existing domain.
For example I have the following two domains:
test1.com
test2.com
Now suppose I have done hosting for test2.com. But now I want that if I open test1.com, that it should open the same content/pages which are displayed in test2.com. I do not want to redirect from test1.com to test2.com. URL should be same as it is i.e test1.com. Is this possible?
I have cpanel hosting.
Please add an url redirect record from your cpanel.
Record-
First domain will be forwarded to second domain.
You can just add the second domain name as parked from cPanel -> Parked domains. It will achieve what you are trying to do:
https://documentation.cpanel.net/display/ALD/Park+a+Domain
Please note however that if you are running WordPress for example, as it is a URL dependable application, it might rewrite your URL.

Redirecting from subdomain to query string

There is a list of options in my website home page - for example, http://example.com. When a user clicks on option1, I want to show the URL as http://option1.example.com and not http://example.com/xyz.php?opt=option1. Any help or guidance would be appreciated.
You will either need to create a subdomain for each option and then provide the required code at that subdomain. how you set that up varies by hosting provider.
Do you really need a seperate subdomain per option?
Could you use http://abc.ca/Option1/ or http://abc.ca/Options/1/ instead?
If not you will need to contact your hosting providers about creating subdomains option1.abc.ca etc and where to put your php pages.
If you are hosting your own server with apache, I think it is possible to use a * dns entry to accept all subdomains and then you can use $_SERVER variables to get the domain being requested.

How can I redirect example.com to some.site.com/example while still showing example.com as the URL?

To restate the question:
I own the example.com domain name. My actual webhost (courtesy of a friend) is some.site.com.
I'd like people to be able to go to example.com and see some.site.com/example/. The thing is, I only want the URL bar to show example.com/whateverpage.html.
I've been studying and experimenting with mod_rewrite, but can't quite figure it out. Is this at all possible?
You could just host a basic web page with an iframe. How complicated is the site?
Who provides your dns - sometimes they have a web forwarding setting just for this.
And are you sure you can't just change the domain name on the site you are pulling from?
You need a CNAME record in your DNS that aliases some.site.com as example.com.
http://en.wikipedia.org/wiki/CNAME_record
If you or your friend don't have access to, or don't know how to modify the DNS server... Contact the HOSTING PROVIDER that is hosting the site, they should know how to make DNS CNAME records correctly. The wiki above has a few examples of what a CNAME record looks like.