Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk11 min

How to Point a Subdomain to a Specific Directory (DNS, cPanel, and NGINX)

DNS sends a subdomain to a server; cPanel or NGINX then maps that hostname to a document-root directory. Follow the exact setup and troubleshooting steps for separate static files or a proxied application.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Pointing a subdomain at a directory requires two separate settings: DNS sends the hostname to the right server, and the web server maps that hostname to a document-root directory. DNS cannot select a folder by itself. In cPanel, create the subdomain with Share document root disabled and enter the target directory. In NGINX, match the hostname with server_name and set the directory with root.

What “point a subdomain to a directory” actually means

Suppose you want blog.example.com to serve files stored in /home/user/public_html/blog. A browser first looks up blog.example.com in DNS. The DNS answer is normally an IP address, such as the public address of your hosting server. Once the request reaches that server, the web server examines the hostname and chooses a virtual-host or server-block configuration. That configuration sets the document root, the directory from which public files are served.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Those layers have different jobs:

  • DNS: maps the hostname to an IP address. It has no knowledge of your filesystem and cannot choose /home/user/public_html/blog.
  • Web-server configuration: maps the hostname to a document-root directory and decides how requests are handled.
  • Application configuration: may proxy requests to a running app instead of reading files from a directory. That is a different arrangement from static-file hosting.

A successful setup therefore needs both a DNS record and a matching server configuration. If either layer is missing, the subdomain may show a DNS error, the wrong website, a default page, or an application response from another virtual host.

Decide what the subdomain should serve

Static files from a directory

Use a document root when the subdomain should return files such as HTML, CSS, JavaScript, images, downloads, or a PHP application handled by the hosting stack. The directory must exist, be readable by the web server, and contain an entry file such as index.html or the entry point expected by your application.

#1 Best Overall
Sale
TP-Link AX1800 WiFi 6 Router (Archer AX21 V5) | Dual Band Wireless Internet, Gigabit, Easy Mesh, Works with Alexa - A Certified for Humans Device
  • DUAL-BAND WIFI 6 ROUTER: Wi-Fi 6(802.11ax) technology achieves faster speeds, greater capacity and reduced network congestion compared to the previous gen. All WiFi routers require a separate modem. Dual-Band WiFi routers do not support the 6 GHz band.
  • AX1800: Enjoy smoother and more stable streaming, gaming, downloading with 1.8 Gbps total bandwidth (up to 1200 Mbps on 5 GHz and up to 574 Mbps on 2.4 GHz). Performance varies by conditions, distance to devices, and obstacles such as walls.
  • CONNECT MORE DEVICES: Wi-Fi 6 technology communicates more data to more devices simultaneously using revolutionary OFDMA technology
  • EXTENSIVE COVERAGE: Achieve the strong, reliable WiFi coverage with Archer AX1800 as it focuses signal strength to your devices far away using Beamforming technology, 4 high-gain antennas and an advanced front-end module (FEM) chipset
  • OUR CYBERSECURITY COMMITMENT: TP-Link is a signatory of the U.S. Cybersecurity and Infrastructure Security Agency’s (CISA) Secure-by-Design pledge. This device is designed, built, and maintained, with advanced security as a core requirement.

A web application through a proxy

If the subdomain is meant to reach a Node, Python, Ruby, or other long-running application, the hosting panel may switch the domain into reverse-proxy mode. In that mode, requests are forwarded to the application process rather than served directly from a filesystem directory. cPanel’s documentation describes these as separate modes: a domain serves either its document root or a proxied web app, not both at once. Do not enter an application port where a document-root path is required, and do not expect a proxy target to behave like a folder.

Choose the path before creating the hostname

Use an absolute path that is inside the account’s permitted home directory. On cPanel, the domain’s file-system location is recorded relative to the cPanel account’s home directory. Decide whether you want a new, empty directory or an existing directory that already contains the site. Avoid pointing two unrelated sites at the same directory unless you deliberately want them to share every file, upload, and configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

cPanel: create a subdomain with its own document root

The labels below follow cPanel’s current Domains interface. cPanel Support’s procedure published April 11, 2026, specifically instructs users to deselect Share document root and then enter the directory where the subdomain’s files should exist.

Rank #2
Sale
TP-Link BE6500 Dual-Band WiFi 7 Router (BE400) | Dual 2.5Gbps Ports, USB 3.0, Covers up to 2,400 sq. ft., 90 Devices, Quad-Core CPU, HomeShield, Private IoT
  • 𝐅𝐮𝐭𝐮𝐫𝐞-𝐑𝐞𝐚𝐝𝐲 𝐖𝐢-𝐅𝐢 𝟕 - Designed with the latest Wi-Fi 7 technology, featuring Multi-Link Operation (MLO), Multi-RUs, and 4K-QAM. Achieve optimized performance on latest WiFi 7 laptops and devices, like the iPhone 16 Pro, and Samsung Galaxy S24 Ultra.
  • 𝟔-𝐒𝐭𝐫𝐞𝐚𝐦, 𝐃𝐮𝐚𝐥-𝐁𝐚𝐧𝐝 𝐖𝐢-𝐅𝐢 𝐰𝐢𝐭𝐡 𝟔.𝟓 𝐆𝐛𝐩𝐬 𝐓𝐨𝐭𝐚𝐥 𝐁𝐚𝐧𝐝𝐰𝐢𝐝𝐭𝐡 - Achieve full speeds of up to 5764 Mbps on the 5GHz band and 688 Mbps on the 2.4 GHz band with 6 streams. Enjoy seamless 4K/8K streaming, AR/VR gaming, and incredibly fast downloads/uploads.
  • 𝐖𝐢𝐝𝐞 𝐂𝐨𝐯𝐞𝐫𝐚𝐠𝐞 𝐰𝐢𝐭𝐡 𝐒𝐭𝐫𝐨𝐧𝐠 𝐂𝐨𝐧𝐧𝐞𝐜𝐭𝐢𝐨𝐧 - Get up to 2,400 sq. ft. max coverage for up to 90 devices at a time. 6x high performance antennas and Beamforming technology, ensures reliable connections for remote workers, gamers, students, and more.
  • 𝐔𝐥𝐭𝐫𝐚-𝐅𝐚𝐬𝐭 𝟐.𝟓 𝐆𝐛𝐩𝐬 𝐖𝐢𝐫𝐞𝐝 𝐏𝐞𝐫𝐟𝐨𝐫𝐦𝐚𝐧𝐜𝐞 - 1x 2.5 Gbps WAN/LAN port, 1x 2.5 Gbps LAN port and 3x 1 Gbps LAN ports offer high-speed data transmissions.³ Integrate with a multi-gig modem for gigplus internet.
  • 𝐎𝐮𝐫 𝐂𝐲𝐛𝐞𝐫𝐬𝐞𝐜𝐮𝐫𝐢𝐭𝐲 𝐂𝐨𝐦𝐦𝐢𝐭𝐦𝐞𝐧𝐭 - TP-Link is a signatory of the U.S. Cybersecurity and Infrastructure Security Agency’s (CISA) Secure-by-Design pledge. This device is designed, built, and maintained, with advanced security as a core requirement.
  1. Sign in to the correct cPanel account. Use the account that owns the parent domain. If you manage several accounts, confirm that the parent domain is listed in this account before changing anything.
  2. Open the domain manager. In cPanel, open Domains, then choose Create A New Domain.
  3. Enter the fully qualified hostname. Type the complete subdomain, for example blog.example.com. Do not enter only blog if the form expects a domain name.
  4. Disable shared document root. Clear Share document root (/home/username/public_html) with “domain.tld”. Leaving this option enabled makes the subdomain use the parent domain’s document root, which defeats the purpose of a separate directory.
  5. Enter the target directory. In the file-system location field, enter the directory in which the subdomain’s files should live. Use the path format accepted by your account; cPanel records the location relative to the account home directory.
  6. Submit the form. cPanel creates the domain mapping and, where the account controls DNS, may create the corresponding DNS entry. The exact confirmation and automatically created folders depend on the host’s configuration.
  7. Place an entry file in the directory. Upload an index.html file or the application’s expected entry file. A correctly mapped but empty directory can otherwise produce a directory-index error or a blank/default response.
  8. Test the exact hostname. Open https://blog.example.com or http://blog.example.com, depending on whether TLS has already been configured. Test the subdomain, not just the parent domain, and check that the returned content is unique to the target directory.

What the cPanel fields control

cPanel setting Effect Common mistake
New Domain Creates the hostname that cPanel will recognize. Entering an incomplete name or a different spelling from the DNS record.
Share document root When enabled, the new hostname serves the parent domain’s existing root; when disabled, it can have its own location. Leaving it enabled and assuming the directory field will still be used.
File System Location Defines the directory relative to the cPanel account’s home directory, as described in cPanel & WHM documentation updated July 22, 2026. Choosing a directory that does not exist, is outside the account’s permissions, or contains the wrong site.

Set the DNS record at the authoritative provider

After the server-side mapping exists, create or verify an A record for the subdomain at the DNS provider authoritative for example.com. Set the record’s value to the public IP address of the server where the document root was configured. A typical record is conceptually:

Name Type Value Purpose
blog or blog.example.com, according to the provider’s form A Your hosting server’s public IPv4 address Sends requests for the subdomain to the server that contains the virtual-host mapping.

Use the provider’s exact name format. Some DNS dashboards append the parent domain automatically when you enter blog; others expect the full hostname. Entering blog.example.com.example.com is a common error in dashboards that append the zone name.

When DNS is managed outside cPanel

If your hosting server does not manage the parent domain’s DNS, adding the subdomain only in cPanel is insufficient. Edit the DNS zone at the external authoritative provider and add the A record there. cPanel’s support documentation makes the same distinction for wildcard subdomains: when cPanel does not manage the root domain’s DNS, the record must be added manually on the server that manages that zone.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
TP-Link Dual-Band AX3000 Wi-Fi 6 Wireless Gigabit Internet Router for Home | EasyMesh, VPN Clients & Server, HomeShield, OFDMA, MU-MIMO, USB 3.0, Secure by Design - Archer AX55
  • Next-Gen Gigabit Wi-Fi 6 Speeds: 2402 Mbps on 5 GHz and 574 Mbps on 2.4 GHz bands ensure smoother streaming and faster downloads; support VPN server and VPN client¹
  • A More Responsive Experience: Enjoy smooth gaming, video streaming, and live feeds simultaneously. OFDMA makes your Wi-Fi stronger by allowing multiple clients to share one band at the same time, cutting latency and jitter.²
  • Expanded Wi-Fi Coverage: 4 high-gain external antennas and Beamforming technology combine to extend strong, reliable, Wi-Fi throughout your home.
  • Improved Battery Life: Target Wake Time helps your devices to communicate efficiently while consuming less power.
  • Improved Cooling Design: No heat ups, no throttles. A larger heat sink and redefined case design cools the WiFi 6 system and enables your network to stay at top speeds in more versatile environments.

Allow for caching without promising a fixed time

Resolvers cache DNS answers according to the record’s TTL and their own policies. A newly added or changed record can therefore remain invisible to some networks while others already use the new address. There is no universal propagation time. Verify the authoritative record first, then allow provider- and TTL-dependent caching to expire before treating an intermittent result as a server configuration failure.

NGINX: map the hostname with a server block

When you control NGINX directly, the essential configuration is a server block that matches the requested hostname and sets the document root. NGINX’s documentation demonstrates the pattern with a root directive such as root /sites/$domain;. A concrete static-site block can look like this:

server {
    listen 80;
    server_name blog.example.com;
    root /home/user/public_html/blog;
    index index.html;
}

The example shows the relationship, not a complete production configuration. Your existing setup may require a different listener, TLS settings, PHP handler, access rules, or an application front controller. Keep the exact hostname in server_name; a typo or an unintended wildcard can cause another server block to answer first.

Rank #4
TP-Link AC1200 Gigabit Dual Band WiFi Router (Archer A6) | MU-MIMO Wireless Internet Router, 4 x Antennas, OneMesh and AP Mode, Long Range Coverage
  • Dual band router upgrades to 1200 Mbps high speed internet (300mbps for 2.4GHz plus 900Mbps for 5GHz), reducing buffering and ideal for 4K stream
  • Full Gigabit Ports - Gigabit Router with 4 Gigabit LAN ports, ideal for any internet plan and allow you to directly connect your wired devices
  • Boosted Coverage - Four external antennas equipped with Beamforming technology extend and concentrate the Wi-Fi signals
  • MU-MIMO technology - (5GHz band) allows high speeds for multiple devices simultaneously
  • Access Point Mode - Supports AP Mode to transform your wired connection into wireless network, an ideal wireless router for home

Apply the NGINX change safely

  1. Create or edit the server configuration used by the account or domain.
  2. Set server_name to the exact subdomain, such as blog.example.com. Add a www name only if you have separately created and intend to serve that hostname.
  3. Set root to the directory containing the public files. Confirm the directory exists and is readable by the NGINX worker process.
  4. Set an appropriate index directive or application routing rule.
  5. Validate the configuration with the validation command provided by your operating system or hosting provider before reloading NGINX.
  6. Reload NGINX using your provider’s documented method, then request the hostname again.

NGINX on cPanel

On cPanel installations that use NGINX, per-domain customizations are stored under a user/domain include path such as /etc/nginx/conf.d/users/username/domainname/. The exact include filename and directives depend on the existing server block and the application. After creating the documented include, cPanel’s procedure requires running /usr/local/cpanel/scripts/ea-nginx so the generated NGINX configuration incorporates the change. Do not edit a generated file that your control panel will overwrite; use the supported per-user or per-domain include location instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep static hosting and proxying separate

A directory mapping answers the question, “Which files should this hostname serve?” A reverse proxy answers, “Which running service should receive this request?” They can coexist on one server, but a single domain configuration must have a clear primary mode.

  • For a static site, the request should resolve to a document root and an entry file.
  • For a proxied app, the configuration should forward requests to the application process and port defined by the hosting platform.
  • If a panel reports that the domain is configured for an application, changing a folder alone will not make the app serve static files from that folder.
  • If an old proxy, redirect, or virtual host still matches first, the browser may never reach the directory mapping you created.

HTTPS and hostname coverage

DNS and document-root settings do not automatically prove that HTTPS is ready. The certificate presented for blog.example.com must cover that exact hostname. Check the hosting panel’s SSL status after creating the subdomain, and make sure the certificate issuance or renewal process includes the new name. Test the HTTPS URL directly; a certificate for only example.com does not necessarily cover blog.example.com.

Verify each layer in order

Testing in sequence prevents you from debugging the wrong layer.

  1. Check the authoritative DNS answer. Query the A record with a DNS diagnostic tool such as dig +short blog.example.com or use the provider’s record viewer. The returned address should be the public IP of the intended server.
  2. Check the server mapping. Confirm that the hostname appears exactly in the cPanel domain list or NGINX server_name configuration and that the document root is the intended directory.
  3. Check the filesystem. Confirm the directory exists, the web-server user can traverse it, and the expected entry file is present with readable permissions.
  4. Check the response. Request the hostname with a browser or curl -I https://blog.example.com. A response from the wrong site usually indicates a hostname mismatch, an earlier virtual host, or a proxy/redirect.
  5. Check logs. If the request reaches the server but fails, inspect the relevant NGINX, Apache, or hosting-panel error log for permission errors, missing files, redirect loops, or upstream failures.

Troubleshooting by symptom

What you see Likely cause What to check next
DNS name does not resolve No A record, a record at the wrong DNS provider, or cached old data. Identify the authoritative provider, verify the A record and IP, and account for TTL-based caching.
Parent website appears The subdomain shares the parent document root or the request matched the parent virtual host. In cPanel, disable Share document root; in NGINX, verify the exact server_name and server-block order.
Default NGINX or hosting page appears The hostname reached the server but no matching configuration was loaded. Check spelling, include-file placement, configuration generation, and reload status.
404 for the home page The mapped directory lacks the configured index file, or application routing is incomplete. Place the expected entry file in the directory and check the index or front-controller setting.
403 Forbidden The directory or file is not readable, directory traversal permissions are missing, or access rules deny the request. Check ownership, permissions, parent-directory traversal, and server access directives.
Old content appears after a change A resolver, browser, CDN, or server-side cache still holds the previous result. Confirm the authoritative DNS answer and server configuration before clearing local caches or waiting for TTL expiry.
HTTPS warning The certificate does not include the new subdomain or the HTTPS virtual host is not mapped to the same content. Issue or renew a certificate covering the exact hostname and inspect the TLS server block.
Application response instead of files The domain is configured for proxying rather than static document-root serving. Choose the intended mode and remove or adjust the conflicting proxy configuration through the hosting panel or server configuration.

Compare hosting approaches before you commit

The easiest method depends on what your provider lets you control. Evaluate the following capabilities rather than assuming every plan exposes the same settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Capability Why it matters Question to ask the provider
Separate document roots Without this, a subdomain may be forced to use the parent site’s directory. Can each subdomain have an independent file-system location?
DNS management in the same account One account can make the DNS and server changes easier to coordinate. Does the control panel manage the authoritative zone, or must I edit DNS elsewhere?
Web-server configuration access Direct NGINX or Apache access is useful when the panel cannot express a custom mapping. Can I add a supported per-domain configuration or include?
Clear static-versus-proxy controls Confusing a proxy target with a directory is a frequent source of wrong responses. Can the domain be explicitly configured for static files or for an application proxy?
SSL coverage The hostname may work over HTTP while HTTPS fails or serves a different virtual host. Will certificates include newly created subdomains, and how are they renewed?

Operational and security checks

  • Keep the document root limited to files that are intended to be public. Store secrets, backups, and deployment credentials outside it.
  • Use the least permissive ownership and file permissions that still allow the web server to read the site and the deployment process to update it.
  • Do not place a control-panel configuration file, environment file, private key, or database dump in a publicly served directory.
  • Record which DNS provider is authoritative and which server configuration owns the hostname. This makes later migrations and incident response faster.
  • After changing the mapping, test both the bare subdomain and any intentionally configured alternate hostname. A record for blog.example.com does not automatically configure www.blog.example.com.
  • When removing a subdomain, delete or disable its DNS record and server mapping deliberately. Leaving one layer active can expose an unintended default site or create confusing errors.

Quick decision guide

  1. If you use cPanel and only need a normal folder, create the domain in Domains, clear Share document root, enter the directory, and place the entry file there.
  2. If DNS is hosted elsewhere, add the subdomain’s A record at that authoritative provider and point it to the server’s public IP.
  3. If you administer NGINX, create a hostname-matching server block and set its root to the target directory, then validate and reload the configuration.
  4. If the site is a running application, configure the hosting platform’s proxy mode instead of treating its port as a filesystem path.
  5. If the result is wrong, check DNS, hostname matching, directory existence and permissions, competing virtual hosts, proxy settings, and SSL coverage in that order.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.