{"id":1487,"date":"2026-09-03T12:16:54","date_gmt":"2026-09-03T06:46:54","guid":{"rendered":"https:\/\/cpanelfree.com\/blog\/how-to-create-subdomains-wildcard-cpanel-guide\/"},"modified":"2026-09-03T12:31:12","modified_gmt":"2026-09-03T07:01:12","slug":"how-to-create-subdomains-wildcard-cpanel-guide","status":"publish","type":"post","link":"https:\/\/cpanelfree.com\/blog\/how-to-create-subdomains-wildcard-cpanel-guide\/","title":{"rendered":"How to Create Subdomains and Wildcard Subdomains in cPanel (Full Tutorial)"},"content":{"rendered":"<div style=\"background-color: #f8fafc;border-left: 4px solid #0ea5e9;padding: 20px;border-radius: 6px;margin-bottom: 25px\">\n<p style=\"margin: 0;font-size: 16px;color: #1e293b\">\n        <strong>Quick Answer:<\/strong> To create a subdomain in cPanel, navigate to <strong>Domains<\/strong>, click <strong>Create a New Domain<\/strong>, enter your subdomain (e.g. <code>staging.yourdomain.com<\/code>), uncheck &#8220;Share document root&#8221;, and specify a custom directory path (<code>public_html\/staging<\/code>). For <strong>Wildcard Subdomains<\/strong>, create a domain named <code>*.yourdomain.com<\/code> and point DNS A record <code>*<\/code> to your server IP.\n    <\/p>\n<\/div>\n<h2>Why Use Subdomains vs Subdirectories?<\/h2>\n<p>A <strong>subdomain<\/strong> (e.g. <code>blog.yourdomain.com<\/code> or <code>app.yourdomain.com<\/code>) operates as an independent web application with its own isolated file directory, independent SSL certificates, and separate database connections. This makes subdomains the ideal architecture for staging environments, client portals, SaaS customer tenants, and standalone WordPress installations.<\/p>\n<h2>Step-by-Step: Creating a Standard Subdomain in cPanel<\/h2>\n<ol style=\"padding-left: 20px;line-height: 1.8\">\n<li>Log in to your <a href=\"https:\/\/cpanelfree.com\/\">CpanelFree<\/a> dashboard and click on <strong>Domains<\/strong> under the Domains category.<\/li>\n<li>Click the blue <strong>Create A New Domain<\/strong> button.<\/li>\n<li>In the <em>Domain<\/em> text box, enter your desired subdomain (e.g. <code>staging.yourdomain.com<\/code>).<\/li>\n<li><strong>CRITICAL:<\/strong> Uncheck the box that says <em>&#8220;Share document root (\/home\/username\/public_html) with domain.com&#8221;<\/em>.<\/li>\n<li>Set the Document Root path to <code>public_html\/staging<\/code> (or <code>staging.yourdomain.com<\/code>).<\/li>\n<li>Click <strong>Submit<\/strong>. cPanel automatically creates the folder structure, Apache virtual host, and DNS zone record.<\/li>\n<\/ol>\n<h2>How to Set Up Wildcard Subdomains (*.yourdomain.com)<\/h2>\n<p><strong>Wildcard subdomains<\/strong> allow your web server to dynamically route any requested subdomain (e.g. <code>user1.yourdomain.com<\/code>, <code>tenant42.yourdomain.com<\/code>) to a single application without creating individual cPanel records for each user. This is essential for <strong>WordPress Multisite (Network)<\/strong> and multi-tenant SaaS platforms.<\/p>\n<h3>1. Create Wildcard Domain in cPanel:<\/h3>\n<p>Create a new domain in cPanel using the asterisk symbol: <code>*.yourdomain.com<\/code> with document root set to your main application folder (<code>public_html<\/code>).<\/p>\n<h3>2. Add Wildcard DNS A Record:<\/h3>\n<p>In cPanel Zone Editor or Cloudflare, add an A record with Name: <code>*<\/code> pointing to your server IP address.<\/p>\n<h2>Automated AutoSSL Issuance for Subdomains<\/h2>\n<p>Within 15 minutes of creating your subdomain, cPanel AutoSSL automatically communicates with Sectigo \/ Let&#8217;s Encrypt to provision a free, trusted SSL certificate covering both your standard and wildcard subdomains.<\/p>\n<h2>Configuring Document Roots and Isolated Apache VirtualHosts<\/h2>\n<p>When creating subdomains in cPanel, isolating the Document Root outside of the main <code>public_html<\/code> folder (e.g. <code>\/home\/username\/subdomains\/staging<\/code>) provides critical security advantages:<\/p>\n<ul style=\"padding-left: 20px;line-height: 1.8\">\n<li><strong>Prevent .htaccess Inheritance:<\/strong> Subdomains placed inside <code>public_html\/subdomain\/<\/code> inherit rewrite rules and security directives from the root domain&#8217;s <code>.htaccess<\/code> file, which often causes redirection loops.<\/li>\n<li><strong>Malware Containment:<\/strong> If a staging subdomain is compromised by a vulnerable test plugin, isolating its document root prevents malicious PHP webshells from reading the parent website&#8217;s <code>wp-config.php<\/code> database credentials.<\/li>\n<\/ul>\n<h2>Automated WordPress Multisite Wildcard Subdomain Routing<\/h2>\n<p>To configure a multi-tenant WordPress Network using subdomains, add this line to your <code>wp-config.php<\/code> file:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\">\/* Enable WordPress Multisite Subdomains *\/\ndefine('WP_ALLOW_MULTISITE', true);\ndefine('MULTISITE', true);\ndefine('SUBDOMAIN_INSTALL', true);\ndefine('DOMAIN_CURRENT_SITE', 'yourdomain.com');\ndefine('PATH_CURRENT_SITE', '\/');\ndefine('SITE_ID_CURRENT_SITE', 1);\ndefine('BLOG_ID_CURRENT_SITE', 1);<\/pre>\n<p>Paired with a wildcard DNS A record (<code>*<\/code>), WordPress will dynamically spawn fully functional sub-sites instantly upon user registration.<\/p>\n<h2>Managing Subdomain Security and SSL Certificates with cPanel AutoSSL<\/h2>\n<p>Whenever a new subdomain is created in cPanel, the automated AutoSSL engine queues the subdomain for domain-control validation (DCV). To ensure smooth validation without manual intervention:<\/p>\n<ul style=\"padding-left: 20px;line-height: 1.8\">\n<li>Ensure the subdomain&#8217;s DNS A record points directly to your cPanel shared IP address.<\/li>\n<li>Do not place restrictive <code>.htaccess<\/code> password protection rules on the <code>.well-known\/acme-challenge\/<\/code> validation directory.<\/li>\n<li>Run manual certificate issuance in cPanel under <strong>SSL\/TLS Status &gt; Run AutoSSL<\/strong> to expedite immediate provisioning.<\/li>\n<\/ul>\n<h2>Configuring Staging Environments with Basic HTTP Authentication<\/h2>\n<p>To prevent search engine bots (Googlebot) from indexing incomplete staging subdomains and hurting your primary site&#8217;s SEO, protect the staging directory with cPanel Directory Privacy:<\/p>\n<ol style=\"padding-left: 20px;line-height: 1.8\">\n<li>In cPanel, click <strong>Directory Privacy<\/strong> under the <em>Files<\/em> section.<\/li>\n<li>Navigate to <code>public_html\/staging<\/code> and check <strong>Password protect this directory<\/strong>.<\/li>\n<li>Create an authorized username and strong password for your development team.<\/li>\n<\/ol>\n<div style=\"background-color: #f8fafc;border: 1px solid #e2e8f0;border-left: 4px solid #0ea5e9;padding: 20px;border-radius: 8px;margin: 30px 0\">\n<h3 style=\"margin-top: 0;color: #0f172a;font-size: 18px;display: flex;align-items: center\">\n        <span style=\"margin-right: 8px\">\ud83d\udd17<\/span> Recommended Related Technical Guides:<br \/>\n    <\/h3>\n<ul style=\"margin: 10px 0 0 0;padding-left: 20px;line-height: 1.8\">\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-setup-free-cloudflare-cdn-dns-hosting\/\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">How to Set Up Free Cloudflare CDN &amp; DNS on Any Web Hosting<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/dns-a-record-vs-cname-vs-alias-guide\/\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">DNS A Record vs CNAME vs ALIAS Explained<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-fix-dns-probe-finished-nxdomain-error\/\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">How to Fix DNS_PROBE_FINISHED_NXDOMAIN Error<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/best-free-web-hosting-2026\/\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">Top 10 Best Free Web Hosting Services<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/#plans\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">Explore $0 Free cPanel Web Hosting Plans<\/a><\/li>\n<\/ul>\n<\/div>\n<div style=\"background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);border: 1px solid #334155;border-radius: 12px;padding: 25px;margin: 30px 0;text-align: center\">\n<h3 style=\"color: #38bdf8;margin-top: 0;font-size: 20px\">Unlimited Free Subdomains on CpanelFree<\/h3>\n<p style=\"color: #94a3b8;font-size: 14px;line-height: 1.6;max-width: 600px;margin: 0 auto 15px\">\n        Create unlimited subdomains, staging sites, and MySQL databases with 100% free cPanel hosting on <strong>CpanelFree<\/strong>.\n    <\/p>\n<p>    <a href=\"https:\/\/cpanelfree.com\/free-wordpress-hosting\" style=\"display: inline-block;background-color: #0ea5e9;color: #ffffff;padding: 10px 22px;border-radius: 6px;text-decoration: none;font-weight: bold;font-size: 14px\">Launch Free Hosting<\/a>\n<\/div>\n<h2>Frequently Asked Questions<\/h2>\n<div style=\"border-bottom: 1px solid #e2e8f0;padding: 12px 0\">\n<h4 style=\"margin: 0 0 8px 0;color: #1e293b\">Can I install WordPress on a subdomain independently?<\/h4>\n<p style=\"margin: 0;color: #475569;font-size: 14px\">Yes. In Softaculous 1-Click Installer, select your newly created subdomain from the domain dropdown menu to install a clean WordPress instance.<\/p>\n<\/div>\n<h2>Configuring Custom PHP Versions and Environment Limits per Subdomain<\/h2>\n<p>In cPanel&#8217;s <strong>MultiPHP Manager<\/strong>, you can assign different PHP versions (e.g. PHP 8.3 for your main application and PHP 8.1 for a legacy testing staging subdomain) to individual document roots, enabling isolated testing environments without affecting live production traffic.<\/p>\n<div style=\"border-bottom: 1px solid #e2e8f0;padding: 12px 0\">\n<h4 style=\"margin: 0 0 8px 0;color: #1e293b\">Can I configure custom DNS MX records for a subdomain?<\/h4>\n<p style=\"margin: 0;color: #475569;font-size: 14px\">Yes. Using cPanel Zone Editor, you can create dedicated MX records for <code>mail.subdomain.yourdomain.com<\/code> to route subdomain emails to independent mailboxes.<\/p>\n<\/div>\n<p>Leveraging isolated document roots and automated wildcard routing empowers developers to build modular, secure multi-site networks and customer staging portals on cPanel effortlessly.<\/p>\n<div style=\"background-color: #f1f5f9;padding: 15px;border-radius: 8px;margin: 20px 0\">\n<h4 style=\"margin-top: 0;color: #1e293b\">Pro Sysadmin Tip: Forcing HTTPS Redirection on Subdomains<\/h4>\n<p style=\"margin: 0;color: #475569;font-size: 14px\">In your subdomain&#8217;s isolated document root (.htaccess file), enforce permanent HTTPS redirection: <code>RewriteEngine On<\/code> followed by <code>RewriteCond %{HTTPS} off<\/code> and <code>RewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]<\/code> to ensure all traffic is encrypted.<\/p>\n<\/div>\n<p>Regularly auditing your active subdomains and removing obsolete staging directories ensures your server storage remains clean and protected against unauthorized script executions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Quick Answer: To create a subdomain in cPanel, navigate to Domains, click Create a New Domain, enter your subdomain (e.g. staging.yourdomain.com), uncheck &#8220;Share document root&#8221;, and specify a custom directory path (public_html\/staging). For Wildcard Subdomains, create a domain named *.yourdomain.com and point DNS A record * to your server IP. Why Use Subdomains vs Subdirectories? [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1486,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[],"class_list":["post-1487","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1487","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/comments?post=1487"}],"version-history":[{"count":7,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1487\/revisions"}],"predecessor-version":[{"id":1540,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1487\/revisions\/1540"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media\/1486"}],"wp:attachment":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media?parent=1487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/categories?post=1487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/tags?post=1487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}