How to Create Subdomains: A Step-by-Step Guide with Cloudways and Cloudflare
Subdomains are powerful tools for organizing your website, creating separate sections for blogs, e-commerce stores, support portals, or even development environments. They allow you to maintain a clean main domain while offering distinct experiences to your users.
If you're using Cloudways for your hosting and Cloudflare for your DNS management, this guide will walk you through the process of setting up a subdomain seamlessly.
Why Use Subdomains?
Before we dive into the "how," let's quickly touch on the "why":
- Organization: Keep different parts of your website logically separated (e.g., blog.yourdomain.com, shop.yourdomain.com).
- Testing & Development: Create a staging environment like dev.yourdomain.com to test new features or updates without affecting your live site.
- Branding: Subdomains can still feel like part of your main brand while serving a specific purpose.
- SEO: While not a direct ranking factor, a well-structured site with subdomains can improve user experience, which indirectly benefits SEO. For a deeper understanding of search engine optimization, check out our comprehensive guide on What is SEO?. If you're looking to optimize content specifically for your new subdomain, our post on How to Write an SEO-Optimized Blog Post can be incredibly helpful.
The Two Key Players: Cloudways (Hosting) and Cloudflare (DNS)
The process of creating a subdomain involves two main steps:
- Creating the subdomain on your hosting provider (Cloudways): This tells your server to expect traffic for this new subdomain and serves the content you'll place there.
- Adding the DNS record on your DNS manager (Cloudflare): This tells the internet where to find your new subdomain on your Cloudways server.
Let's get started!
Step 1: Create Your Subdomain Application on Cloudways
(You may create a separate application in Cloudways server that handles your subdomain)
Cloudways makes managing applications, including subdomains, incredibly straightforward.
- Log in to your Cloudways Platform: Access your Cloudways account.
- Select Your Server and Application: Navigate to the server where your main domain's application is hosted.
- Click on Applications from the top menu.
- Click Add Application.
- Choose your server, select your desired application (e.g., WordPress, Magento, PHP Custom), and give your application a meaningful name (this will help you identify it later).
- Click Add Application again to confirm. This creates a completely new, isolated environment for your subdomain, which is often recommended for better resource management and security.
- Map Your Subdomain to the Application:
- Once your new application is created, go to its Application Management screen.
- Click on Domain Management.
- Under "Primary Domain," enter your subdomain (e.g., blog.yourdomain.com or dev.yourdomain.com).
- Click Save Changes.
- Cloudways will now configure your server to handle requests for this subdomain. Make sure to note down the Public IP of your server from the Server Management section, as you'll need it for Cloudflare. For more details on managing applications, refer to the Cloudways Application Management documentation.
Step 2: Add the DNS Record in Cloudflare
Now, we need to tell Cloudflare (your DNS provider) where to direct traffic for your new subdomain.
- Log in to your Cloudflare Dashboard: Access your Cloudflare account.
- Select Your Domain: From your Cloudflare dashboard, choose the domain for which you want to create the subdomain.
- Go to DNS Settings: Click on the DNS icon in the top menu.
- Add a New Record:
- Click the Add record button.
- Type: For most subdomains pointing to a specific IP address on your server, you'll choose A (for IPv4) or AAAA (for IPv6). If your Cloudways application provides a CNAME record for Cloudflare integration (especially for Cloudflare Enterprise users), choose CNAME. For this example, we'll assume an A record.
- Name: Enter the desired subdomain prefix (e.g., blog for blog.yourdomain.com, dev for dev.yourdomain.com).
- IPv4 address (for A record) / Target (for CNAME record):
- For A Record: Paste the Public IP address of your Cloudways server (which you noted down earlier).
- For CNAME Record: If Cloudways provided a CNAME target (e.g., secure.cloudways.cloud), enter that here.
- Proxy status (Cloudflare Proxy): It's highly recommended to keep this Proxied (orange cloud) to benefit from Cloudflare's security, performance, and CDN features. This is crucial for maximizing your website's speed and security, especially when combined with practices like Creating Lightweight Elementor Sites for optimal performance.
- TTL (Time To Live): You can usually leave this as Auto.
- Click Save.
SSL Certificates: Ensuring Your Subdomain is Secure
Security is paramount. When setting up a subdomain, ensuring it has a valid SSL certificate is crucial for encrypting data and building user trust. You have a couple of excellent options:
- Cloudways Provided Let's Encrypt SSL Certificate: Cloudways offers free, one-click Let's Encrypt SSL certificates for all your applications.
- Go to your subdomain's application management in Cloudways.
- Click on SSL Certificate.
- Select Let's Encrypt, enter your email, and your subdomain name.
Click Install Certificate.
This is often the simplest and most recommended method, especially if you're not using Cloudflare's full proxy features for SSL. For more details, refer to the Cloudways SSL Installation Guide.
- Cloudflare SSL: Cloudflare provides Universal SSL for all domains managed through their DNS. If your DNS record for the subdomain is "Proxied" (orange cloud), Cloudflare will automatically handle SSL termination at their edge. You can configure different SSL modes (Flexible, Full, Full (strict)) in Cloudflare's SSL/TLS app. For most scenarios, "Full (strict)" is the ideal choice for end-to-end encryption. Learn more about Cloudflare SSL/TLS settings.
Choose the method that best suits your setup and comfort level. Both are highly effective!
Propagation Time
After adding the DNS record in Cloudflare, it can take some time for the changes to propagate across the internet. This is known as DNS propagation and can take anywhere from a few minutes to up to 24-48 hours, though it's often much faster with Cloudflare.
You can use online DNS propagation checkers (search for "DNS propagation checker") to see if your subdomain's DNS records have been updated globally.
Important Considerations:
- Directory Structure: Remember that the content for your subdomain will be served from the application directory you configured on Cloudways for that specific subdomain.
- WordPress Multisite: If you're setting up a WordPress Multisite, the process on Cloudways has specific steps for domain mapping within the WordPress network settings. For a deeper dive into this powerful WordPress feature, read our article on What is a WordPress Multisite and Do You Need It?.
- Maintenance: Just like your main domain, your subdomain application will also require regular maintenance to ensure optimal performance and security. Whether it's an e-commerce store on a subdomain or a blog, our guides on How to Perform E-commerce Website Maintenance and How to Perform WordPress Website Maintenance will be invaluable.
- Troubleshooting: If your subdomain isn't loading, double-check the following:
- Is the IP address in your Cloudflare A record correct and matching your Cloudways server IP?
- Is the subdomain correctly mapped to an application in Cloudways?
- Have you waited long enough for DNS propagation?
- Are there any conflicting DNS records for the subdomain in Cloudflare?
By following these steps, you'll have your subdomains up and running on Cloudways with Cloudflare in no time, giving your website greater flexibility and organization. Happy subdomaining!