Quick Summary – Domain vs URL
A domain is a name in the DNS hierarchy. A URL is a complete address that can include a scheme, host, port, path, query, and fragment.
- Domain name — Identifies a named area in DNS, such as example.com.
- Complete URL — Specifies how to reach a resource, such as https://example.com/docs.
- Host is separate — The host may contain a domain, subdomain, hostname, or IP address.
- DNS layer — DNS resolves names and records; it does not process URL paths such as /blog.
- HTTPS matters — The scheme, hostname, port, and certificate must agree for a secure connection.
- Test separately — Use dig for DNS and curl for HTTP status codes and redirects.
A domain is the name, while a URL is the full address used to reach a resource. In https://example.com:8443/docs?id=4, example.com is the domain, but the URL also tells the client to use HTTPS, connect to port 8443, request /docs, and send a query parameter.
Table of Contents
- The basic difference between a domain and a URL
- What parts make up a URL?
- What is a domain, and how does it work?
- How can you tell a domain from a URL?
- Are domain, hostname, and URL the same thing?
- How do HTTPS, DNS, and redirects relate to domains and URLs?
- Testing domains and URLs from the command line
- Common domain and URL mistakes
- A short decision table for domains and URLs
- Check These Before Troubleshooting
- Frequently Asked Questions
- Sources
The basic difference between a domain and a URL
I still see domain names and URLs treated as if they were interchangeable, especially when someone is troubleshooting a site at an inconvenient hour. They are related, but they answer different questions. A domain is a human-readable name used in DNS. A URL is the complete address that tells a client how to reach a resource.
For example, example.com is a domain name. https://example.com/blog?v=2#dns is a URL. The example.com part is the host’s domain; the URL also carries the scheme, path, query string, and fragment.
This distinction becomes useful when you configure DNS, TLS certificates, redirects, and a web server. DNS resolves a hostname to an IP address or returns other record types. A URL tells the client which scheme to use and which resource to request from that host.
Start here – When you inspect an address, separate the host from the scheme, port, path, query string, and fragment. That small habit prevents several layers from getting mixed together.
What parts make up a URL?
URL syntax follows the general URI structure described in RFC 3986. A browser address can look like this:
https://user:password@www.example.com:8443/store/product?id=42&color=blue#comments
Each part has its own job:
| Part | Example | Purpose |
|---|---|---|
| Scheme | https |
Specifies the protocol used for communication. |
| User information | user:password@ |
Credentials that can be carried in a URL, although you should generally avoid doing this. |
| Host | www.example.com |
The server address, which may be a domain, hostname, or IP address. |
| Port | 8443 |
Specifies the network port used for the connection. |
| Path | /store/product |
The requested resource or application route. |
| Query | ?id=42&color=blue |
Parameters sent to the application. |
| Fragment | #comments |
A client-side location, usually a section selected in the browser. |
https://example.com/ is a valid URL, and its domain is example.com. If no port is written, the client normally uses the scheme’s default port: TCP 80 for HTTP and TCP 443 for HTTPS.
Some clients accept a username and password in a URL, but I avoid it. URLs can turn up in browser history, proxy logs, and web-server logs. Depending on the request and software involved, the URL may also appear in a referrer value.
I made this mistake years ago while testing an internal service: I pasted a URL containing a temporary token into a support ticket. The token was short-lived, but the lesson was not. Keep credentials and secrets out of URLs.
Use instead – Put the site behind HTTPS and use a separate authentication mechanism for administrative access.
Tip
Read a URL from left to right: identify the scheme, isolate the host, and then inspect the port, path, query, and fragment. This prevents DNS and web-server problems from getting mixed together.
What is a domain, and how does it work?
A domain is a name within the DNS hierarchy. DNS can use that name to return IPv4 and IPv6 addresses, mail destinations, verification data, aliases, and other records.
If we split www.example.com into labels:
- www: A label commonly used as a hostname or subdomain.
- example: The second-level part of the domain name.
- com: The top-level domain, or TLD.
The dot to the right of the name represents the DNS root. The fully qualified form can technically be written as www.example.com.; most people leave the final dot out.
Domain registration and web hosting are separate services. Registering a domain gives you control over the name and its delegation. A VPS or hosting account provides the infrastructure where the application and its data run.
A working setup normally involves a registrar, authoritative nameservers, and the required DNS records. A website commonly needs an A or AAAA record, email needs an MX record, and domain verification often uses a TXT record.
dig +short example.com A displays the A record, while dig +short example.com AAAA displays the IPv6 record. Empty output may mean the record is absent or that the resolver returned no answer. It does not prove that the web server is down.
That last distinction has saved me more than once. When a customer reported a dead website, I initially looked at Nginx logs before checking DNS. The logs were quiet because the request was never reaching the server.
Check first – When a site cannot be reached, inspect its A, AAAA, and CNAME records with dig +short before combining DNS and HTTP into one guess.
How can you tell a domain from a URL?
Read the address from left to right. Identify the scheme, isolate the host, and then look at everything after the host. The host can contain a domain or a hostname under that domain. The path, query, and fragment are not part of the domain.
| Address | Domain or host | Extra URL information |
|---|---|---|
example.com |
example.com |
No scheme, path, or parameters are shown. |
https://example.com |
example.com |
The https scheme has been added. |
https://blog.example.com/post |
blog.example.com |
/post is the path. |
https://example.com:8443/app |
example.com |
The URL includes port 8443 and the /app path. |
https://example.com/product?id=8 |
example.com |
The URL includes a path and the id=8 query. |
Here is the detail that often matters in production: blog.example.com and example.com may belong to the same DNS zone, but they are separate hostnames. They can have different DNS records and can point to different IP addresses.
The same applies to example.com, www.example.com, and m.example.com. A web server, TLS certificate, and redirect rule can evaluate each one separately.
The https:// at the beginning of a URL is not the domain. It is the scheme. The domain is part of the host, while the URL describes the complete request address.
Short version: name and address are not the same thing.
Are domain, hostname, and URL the same thing?
They overlap, but they are not synonyms.
- Domain: A name or namespace within the DNS hierarchy. Example:
example.com. - Hostname: A name identifying a particular machine or service on a network. Example:
vps01.example.com. - FQDN: A hostname written with its complete DNS hierarchy. With the root dot included, it is
vps01.example.com.. - URL: An address combining a scheme, host, port, and resource path. Example:
https://vps01.example.com:8443/panel.
vps01.example.com can be a hostname. The same text can be the host portion of a URL, but it is not a complete URL until a scheme is included.
A DNS record and a web URL belong to different layers. An A record maps a hostname to an IPv4 address. An HTTP request carries the host and path from the URL to the web server. Nginx can use the Host header to select the correct virtual server when several sites share one IP address.
This is how several sites can live on one VPS. They may all point to the same IP, while Nginx chooses a different document root or application upstream based on the hostname.
One warning: the Host header is not, by itself, an authentication mechanism. Your application still needs proper access control.
How do HTTPS, DNS, and redirects relate to domains and URLs?
HTTPS is not a domain. During the TLS connection, the client validates a certificate for the hostname it selected. A certificate for example.com does not automatically cover www.example.com; the certificate must include that name or an appropriate wildcard.
When a browser opens https://example.com/product, the process roughly looks like this:
- DNS resolution: The client looks up an A or AAAA record for
example.com. - Connection: HTTPS normally uses TCP port 443. With HTTP/3, QUIC can use UDP port 443.
- TLS validation: The certificate, hostname, and validity period are checked.
- HTTP request: The host and
/productpath are sent to the server. - Application response: The server returns content, an error, or a redirect such as 301 or 302.
A redirect can change the URL’s domain without changing DNS. If http://example.com redirects to https://www.example.com/ with a 301 response, the DNS record has not necessarily changed. The web server or CDN issued the redirect.
During a domain migration, DNS caches and TTL values can cause different resolvers to return different answers for a while. Do not check only in a browser. Test the authoritative nameserver and public resolvers separately. The post What Is DNS Propagation? How Long Does It Take? explains this caching behavior in more detail.
When moving a site from HTTP to HTTPS, check the 301 redirect, canonical URL, certificate coverage, and absolute URLs generated by the application together. What Is a 301 Redirect? An SEO Implementation Guide covers the practical use of permanent redirects.
Test separately – Check the DNS answer, TLS certificate, and HTTP status code as different layers when investigating a redirect problem.
Caution
A redirect does not automatically mean that DNS changed. The DNS answer, TLS certificate, and HTTP response come from different layers and should be tested independently.
Testing domains and URLs from the command line
A browser can hide the original problem with caches, extensions, and browser-specific behavior. I usually start in a terminal. It is less pretty, but the output is honest.
dig +short example.com A
dig +short www.example.com CNAME
curl -I https://www.example.com/
The first two commands inspect DNS records. curl -I requests only the HTTP headers. You may see status codes such as HTTP/2 200, 301, 302, or 404. A 301 or 302 means the request reached a server, but that server sent the client somewhere else.
Use -L to follow and display a redirect chain:
curl -IL https://example.com/
This shows the headers from each redirect step. Two or three unnecessary redirects add latency and can cause cookie or canonical-URL problems in some applications.
To see which resolver is answering:
dig example.com A
dig @1.1.1.1 example.com A
dig @8.8.8.8 example.com A
The first query uses the resolver configured on your system. The other two query specific public resolvers. If the answers differ, inspect TTL, cached data, and the authoritative nameserver configuration. dig +short is easier to read; for deeper troubleshooting, keep the full output.
You can also test a hostname against a specific IP while preserving the hostname used for TLS and HTTP:
curl --resolve example.com:443:203.0.113.10 -I https://example.com/
--resolve creates a temporary IP mapping for the specified host and port. The request still uses example.com, which makes it useful for testing a staging IP without changing public DNS.
I keep a similar command ready when testing changes in my Proxmox lab. It has saved me from changing DNS just to discover that the Nginx virtual-host rule was the real problem. I once changed the wrong test record anyway, because I copied the hostname from an old note instead of checking it with hostname. The command was correct; my target was not.
My order – Check DNS with dig, then verify HTTP and redirects with curl -I.
From the field
I used curl –resolve in my Proxmox lab to test a staging IP while preserving the real hostname for TLS and HTTP. It was cleaner than changing public DNS and waiting for caches to expire.
Common domain and URL mistakes
One frequent mistake is treating the path as part of the domain. In example.com/blog, the domain is example.com and the path is /blog. DNS does not receive /blog; it resolves only the host.
Another mistake is assuming that www and the apex domain are automatically identical. A CNAME may exist for www.example.com, while example.com needs its own A or suitable provider-specific record. A CNAME at the apex depends on support for mechanisms such as ALIAS or ANAME.
A third mistake is treating query parameters as access control. A URL such as /download?file=report.pdf does not authorize anyone to download the file. The application still needs session and permission checks.
A fourth mistake is ignoring URL encoding. Spaces, non-ASCII characters, and special characters such as & must be encoded correctly. The form shown in a browser’s address bar may not be identical to the form parsed by the application.
A fifth mistake is treating http and https as the same origin. An origin is defined by the scheme, host, and port. https://example.com and http://example.com differ by more than one character: their encryption and browser security behavior are different.
With a CDN, the URL can remain unchanged while DNS returns a CDN edge IP. As explained in What Is a CDN? How It Speeds Up Websites, adding a distribution layer between the visitor and the origin changes the request path, not the meaning of the domain.
Do not fix these problems with a broad rewrite rule or a quick chmod 777. That only changes the symptom, and sometimes creates a new problem.
Example
In example.com/blog, DNS resolves example.com and knows nothing about /blog. The path is interpreted only after an HTTP request reaches the web server.
A short decision table for domains and URLs
This table is a quick way to decide which layer deserves your attention:
| Question | Concept to inspect | Example |
|---|---|---|
| Is the name registered? | Domain | example.com |
| Which IP does it resolve to? | DNS record | A or AAAA |
| Which protocol is used? | URL scheme | https:// |
| Which page or API route is requested? | URL path | /api/users |
| Which filter is sent? | Query string | ?page=2 |
| Which section should open? | Fragment | #comments |
| Which application should receive it? | Host and web-server rule | api.example.com |
The short version is this: a domain is the named part of a URL’s host, while a URL is the complete address describing how to reach a resource on that host. Not every domain is a URL. A URL also does not need a registered domain; it can use an IP address or localhost.
For example, http://127.0.0.1:8080/test is a valid URL, but it contains no registered domain. Its host is an IPv4 address. Likewise, file:///home/user/notes.txt is a URL form without a web domain.
Keep this habit – Use “domain” for the name itself and “URL” for the complete address, including its scheme and resource path. When a site misbehaves, inspect those pieces one at a time.
Check These Before Troubleshooting
- Separate the domain or hostname from the complete URL.
- Check A, AAAA, and CNAME records with dig.
- Confirm the URL scheme and port.
- Verify that the TLS certificate covers the requested hostname.
- Inspect HTTP status codes with curl -I.
- Follow redirect chains with curl -IL.
- Test a staging IP with curl –resolve before changing public DNS.
Keep the layers separate: domain and DNS first, then TLS, HTTP, redirects, and application paths. The next time an address looks suspicious, read it one component at a time instead of treating the whole string as a single name.
Frequently Asked Questions
Is a domain the same as a URL?
No. A domain is a human-readable name in the DNS hierarchy, such as example.com. A URL is a complete resource address, such as https://example.com/docs. It can include the scheme, host, port, path, query parameters, and fragment. The domain may be one part of a URL, but the two terms describe different things.
Is www.example.com a domain or a URL?
Without a scheme, www.example.com is a hostname or domain name used in DNS, not a complete URL. Add a scheme and it becomes a URL: https://www.example.com/. The www label is commonly configured as a subdomain or hostname, and it may have a different DNS record, TLS coverage, or web-server rule from example.com.
Does DNS resolve the complete URL?
No. DNS resolves the host name, not the path or query string. For https://example.com/store?id=4, DNS looks up example.com. The /store path and id=4 query are sent later in the HTTP request. This is why adding or removing a URL path does not require a separate DNS record.
Can a URL exist without a domain?
Yes. A URL can use an IPv4 address, IPv6 address, localhost, or a local file path instead of a registered domain. For example, http://127.0.0.1:8080/test is a valid URL whose host is an IP address. The file:///home/user/notes.txt form is also a URL, but it does not identify a web domain.
Why can example.com and www.example.com behave differently?
They are different hostnames, even when they belong to the same DNS zone or point to the same IP address. DNS records, TLS certificates, Nginx virtual-host rules, cookies, and redirects can treat them separately. If one works and the other fails, inspect the DNS record, certificate names, and web-server configuration for each hostname.
What is the best way to troubleshoot a domain or URL problem?
Test each layer separately. Use dig to inspect DNS records and compare resolvers when necessary. Use curl -I to inspect the HTTP response, curl -IL to follow redirects, and curl –resolve to test a specific IP while preserving the hostname. For HTTPS problems, also verify that the certificate covers the exact hostname in the URL.
Sources
- IETF RFC 3986 – Uniform Resource Identifier Syntax — rfc-editor.org
- IETF RFC 9110 – HTTP Semantics — rfc-editor.org
- ICANN – Domain Name System Glossary — icann.org
- IANA – Service Name and Transport Protocol Port Number Registry — iana.org