Table of contents
Subdomain
To host several websites on the same domain, you can make use of subdomains. A subdomain is a subset of your main domain that can be used to create separate websites or distinct sections within your primary domain. Let's use Google as an example to explain the concept.
Google uses subdomains to host various services under the main domain "google.com." Each subdomain represents a different service or product offered by Google. Here are a few examples:
google.com: This is the main website of Google, typically used for general search queries.
mail.google.com: This subdomain hosts Google's email service, known as Gmail.
drive.google.com: This subdomain is dedicated to Google Drive, their cloud storage and file-sharing service.
news.google.com: This subdomain displays news articles and headlines from various sources.
By utilizing subdomains, Google can separate its different services while keeping them all under the umbrella of the main domain. Each subdomain can have its own unique website, content, and functionality.
To set up subdomains for your own domain, you'll need to follow these general steps:
Purchase a domain: Register a domain name from a domain registrar.
Configure DNS settings: Access the domain's DNS (Domain Name System) settings and create appropriate DNS records, specifically "A" or "CNAME" records, to point each subdomain to its corresponding website or server.
Set up hosting: Configure hosting for each subdomain separately. This can involve creating individual directories or virtual hosts on your server to handle the content and functionality of each subdomain.
Develop and deploy websites: Design and develop each subdomain as a separate website, with its own content, design, and functionality.
Test and maintain: Ensure that each subdomain works correctly by testing and troubleshooting any issues that may arise. Regularly update and maintain each subdomain's website independently.
By using this approach, you can host multiple websites under the same domain while keeping them organized and easily accessible through their respective subdomains.
DNS records
In domain DNS (Domain Name System), various types of records are used to manage the association between domain names and their corresponding IP addresses or other services. Here are some common DNS record types and their purposes:
A Record (Address Record): An A record maps a domain name to an IPv4 address. It is used to point a domain directly to an IP address.
AAAA Record (IPv6 Address Record): Similar to the A record, an AAAA record maps a domain name to an IPv6 address. It is used for IPv6 addressing.
CNAME Record (Canonical Name Record): A CNAME record creates an alias for a domain name. It points a domain to another domain name (canonical name). It is commonly used for creating subdomains or redirecting one domain to another.
MX Record (Mail Exchange Record): MX records specify the mail server(s) responsible for accepting email messages for a domain. They are used to direct incoming emails to the appropriate mail servers.
TXT Record (Text Record): TXT records store arbitrary text data associated with a domain. They are commonly used for various purposes such as domain verification, SPF (Sender Policy Framework) records for email authentication, and other verification or configuration information.
NS Record (Name Server Record): NS records specify the authoritative name servers for a domain. They indicate which DNS servers are responsible for providing DNS information about the domain.
SRV Record (Service Record): SRV records define the location of specific services within a domain. They are used for protocols such as SIP (Session Initiation Protocol), XMPP (Extensible Messaging and Presence Protocol), and others.
SPF Record (Sender Policy Framework Record): SPF records are used for email authentication. They specify which servers are authorized to send emails on behalf of a domain, helping to prevent email spoofing and phishing attempts.
These are some of the commonly used DNS record types. Each record type serves a specific purpose in mapping domain names to IP addresses or configuring various services associated with a domain. The configuration of DNS records is typically managed through the domain registrar or the DNS management interface provided by the hosting or DNS service provider.
Google Analogy Subdomain Record
Let's take an example using Google's DNS records and a subdomain called "blog" under the main domain "example.com."
A Record: Suppose you want the subdomain "blog.example.com" to point to a specific IPv4 address. You would create an A record for the "blog" subdomain and associate it with the desired IP address. This would allow visitors to access the blog by typing "blog.example.com" in their browsers.
CNAME Record: Instead of pointing the subdomain "blog.example.com" to a specific IP address, you might want it to redirect to another domain, such as "blog.google.com." In this case, you would create a CNAME record for the "blog" subdomain and set its value as "blog.google.com." This would redirect anyone accessing "blog.example.com" to "blog.google.com" instead.
MX Record: Let's say you want to handle email for the subdomain "blog.example.com" separately from the main domain. You would create an MX record for "blog.example.com" and specify the mail servers responsible for accepting email for that subdomain. This ensures that any emails sent to addresses ending with "@blog.example.com" are correctly routed to the specified mail servers.
TXT Record: TXT records can be used for various purposes, such as domain verification or adding additional information. For example, you might create a TXT record for "blog.example.com" to verify domain ownership or to set up SPF (Sender Policy Framework) records to specify the allowed email senders for that subdomain.
These examples demonstrate how DNS records can be used with a subdomain like "blog.example.com" within the main domain "example.com." Each record type serves a specific purpose and allows you to configure the behavior of the subdomain independently from the main domain.
My example
To create different subdomains under the domain "ayushguptadev.in," you'll need to follow these steps:
Domain Registrar: Ensure that you have access to the domain registrar where you purchased the "ayushguptadev.in" domain. This is where you'll manage the DNS settings.
DNS Management: Log in to your domain registrar's account and navigate to the DNS management or DNS settings section.
Create Subdomains: In the DNS management interface, look for an option to add or create new records. Add the desired subdomains and their corresponding IP addresses or DNS records. Here's an example:
Subdomain: portfolio.ayushguptadev.in
Type: A Record
Value: IP address of the server hosting the portfolio website
Subdomain: ecommerce.ayushguptadev.in
Type: A Record
Value: IP address of the server hosting the ecommerce website
Save Changes: After adding the subdomain records, save the changes in the DNS management interface. The DNS changes may take some time (usually a few minutes to a few hours) to propagate worldwide.
Configure Subdomain Hosting: Once the DNS changes have propagated, you need to configure the hosting for each subdomain:
Portfolio Subdomain: Set up hosting for the "portfolio.ayushguptadev.in" subdomain, pointing it to the server or hosting provider where you have your portfolio website hosted. This may involve configuring virtual hosts or domain settings on the hosting provider's platform.
Ecommerce Subdomain: Similarly, set up hosting for the "ecommerce.ayushguptadev.in" subdomain, pointing it to the server or hosting provider where you have your ecommerce website hosted.
Test the Subdomains: After completing the configuration, test the subdomains by accessing them in a web browser. Ensure that each subdomain loads the corresponding website correctly.
Remember that the exact steps for configuring subdomains may vary depending on your specific domain registrar and hosting provider. It's recommended to refer to the documentation or support resources provided by your domain registrar and hosting provider for detailed instructions tailored to their platforms.