简体   繁体   中英

URL to use for CNAME

I have a server using WHM and on one of the cpanel accounts, I added a subdomain. Then I created a redirect to a new location for that subdomain. It doesn't work. I was told my CNAME record isn't set up right.

So, let's say the domain I want the subdomain to go to is this:

www.newdomain.com?user=888448594

How do I put that in the CNAME record?

I tried to paste that url in and it gave me an error. Looking at documentation for CNAME stuff, it just shows what to do with a regular domain but not one with that part following the domain. Can someone help please?

DNS is the service that translates a hostname into an ip. If you request www.example.com/penguins/are/green/ in your browser, your browser first looks up what ip is associated with www.example.com , because it can only address a server on the world-wide-web with it's ip.

The hostname, or domain name, is the part behind the procotol and until the tld (eg ".com" in the example above). The two records you'll use for simple tasks are:

  • A-record. This translates a hostname to an ip.
  • CNAME-record. This makes an alias for a hostname, or a group of hostnames, to lookup an other hostname instead. A client, such as your browser, will retry with the new hostname until it finds an A record.

Since it is only used to find the correct ip for a particular hostname, it is impossible to do what you want to do with DNS.


What you want to do is make sure that all requests that should arrive at your server, are directed there. It would look something like that.

RecordType  |  Key                | Value
A           | example.com         | 1.2.3.4
CNAME       | www.example.com     | example.com
CNAME       | newdomain.com       | example.com
CNAME       | *.newdomain.com     | example.com

On your server you want to do url rewriting. How this works is different per http deamon. On Apache you use mod_rewrite , for IIS you use their url rewrite module , for lighttpd you use this module and for nginx you use this module . There are plenty of examples on how to do this for each of the http deamons. Since you have not listed your original url, or what you precisely want to do with it, I can't tell what exactly you have to search for. I guess you want an external redirect that redirects an url or domain name to an other domain name with a query string .

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