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 DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
VGSources
Blog

How to Point a Subdomain to a Specific Directory

DNS points a subdomain to a server; cPanel or NGINX maps that hostname to a directory. Follow the exact setup, DNS, HTTPS, and troubleshooting steps.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Pointing a subdomain to a folder requires two separate configurations: DNS sends the hostname to the correct server, and that server maps the hostname to a document-root directory. DNS records cannot select a filesystem path. 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 load files stored in /home/user/public_html/blog. The request passes through two layers:

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.
  1. DNS resolution: An A record maps blog.example.com to the public IP address of the server.
  2. Web-server routing: The server’s virtual-host or domain configuration recognizes blog.example.com and serves files from the configured document root.

Changing DNS alone cannot make a server use /home/user/public_html/blog. Conversely, configuring a directory on the server does nothing if the hostname still resolves somewhere else. Both layers must point to the same server.

The document root is the directory from which the web server serves public files for a hostname. A request for https://blog.example.com/news.html normally looks for news.html beneath that root. The root directory is not necessarily the same as the parent domain’s directory.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Decide which setup you need

Static files from a folder

Use a separate document root when the subdomain should serve HTML, CSS, JavaScript, images, downloads, or a traditional server-rendered site directly from files. The hostname maps to a directory, and the web server returns files from that directory.

An application running on a port

A web application may instead require a reverse proxy. In that arrangement, the subdomain forwards requests to an application process rather than reading files from a directory. cPanel distinguishes these modes: a domain serves content either from its document root or as a proxy to a web app, but not both at once. Do not enter an application’s localhost URL where a document-root path is expected.

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.

Check these prerequisites first

  • You control the account that owns the parent domain.
  • You know which provider is authoritative for the parent domain’s DNS zone.
  • The server has a public IP address that should receive requests for the subdomain.
  • The target directory exists, or you have permission to create it.
  • The directory will contain an entry file such as index.html or the application’s expected entry point.
  • Your hosting plan permits separate document roots and, if needed, custom web-server configuration.
  • You have a plan for HTTPS; the certificate must cover the new subdomain.

Write down the exact hostname, including spelling and whether you intend to use a www variant. A configuration for blog.example.com does not automatically configure www.blog.example.com.

cPanel: create a subdomain with its own directory

The current cPanel workflow places subdomain creation under the Domains interface. Labels can vary slightly by theme or hosting provider, but the essential setting is whether the new domain shares the parent domain’s document root.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
  1. Sign in to cPanel for the account that owns the parent domain.
  2. Open Domains, then choose Create A New Domain.
  3. Enter the fully qualified hostname, for example blog.example.com.
  4. Clear Share document root (/home/username/public_html) with “domain.tld”. Leaving this selected makes the subdomain use the main domain’s files instead of a separate directory.
  5. In the document-root or file-system-location field, enter the directory where the subdomain’s files should live. Use the path format expected by your account; cPanel stores it relative to the account’s home directory in its domain configuration.
  6. Submit the form and wait for cPanel to create or register the domain configuration.
  7. Place an index.html file, or the appropriate application entry file, in the selected directory.
  8. After DNS resolves, open the exact hostname in a browser and verify that the expected file is returned.

cPanel’s support procedure, published April 11, 2026, specifically instructs users to deselect the sharing option and then “enter the directory where you want the files for this subdomain to exist.” The document root defines the domain’s directory relative to the cPanel account’s home directory.

Example directory layout

/home/username/
├── public_html/              # example.com
└── public_html/blog/         # blog.example.com

With that arrangement, a request for https://blog.example.com/index.html should read /home/username/public_html/blog/index.html, provided the cPanel domain configuration and DNS both refer to the same host.

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

Configure DNS at the authoritative provider

Create or verify an A record for the subdomain in the DNS zone that is authoritative for example.com. The value should be the public IP address of the server where the cPanel or NGINX document root is configured.

DNS field Example value Purpose
Type A Maps a hostname to an IPv4 address.
Name/Host blog or blog.example.com, depending on the provider Identifies the subdomain within the parent zone.
Value/Target 203.0.113.25 (example only) The server’s public IPv4 address.
TTL Provider default or your chosen value Controls how long recursive resolvers may cache the answer.

Use the name format required by your DNS provider; some interfaces append the parent domain automatically. If your hosting server does not manage DNS, add the record manually at the external DNS provider. cPanel’s documentation notes that when the cPanel server does not manage the root domain’s DNS, records must be added in the zone on the server that does.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

DNS changes do not become visible at exactly the same time everywhere. Recursive resolvers can continue using cached data until the record’s TTL expires, so timing depends on the provider, the previous TTL, and individual resolver caches. Do not treat a short local delay as proof that the server configuration is wrong.

Confirm which provider is authoritative

Change the record where the parent domain’s authoritative name servers host the zone. Editing a DNS panel that is not authoritative will have no effect, even if it displays a record with the same name. Your registrar, DNS host, or hosting control panel can show the active name servers.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

NGINX: map the hostname to a directory

NGINX selects a server block by comparing the request’s hostname with server_name. The root directive then identifies the directory from which static files are served.

server {
    listen 80;
    server_name blog.example.com;

    root /home/user/public_html/blog;
    index index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }
}

Replace the hostname and path with your actual values. The root path must exist and be readable by the NGINX worker process. The example returns a 404 when the requested file is absent; an application that needs front-controller routing may require a different try_files rule.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

After adding or changing a server block, validate the configuration with your system’s NGINX configuration-test command, reload NGINX, and inspect the error log if the reload fails. The exact service command depends on the operating system and how NGINX was installed, so use the service-management method provided by that system.

Per-domain NGINX customization on cPanel

On cPanel installations that use NGINX, custom configuration is stored per user and domain. cPanel documents per-domain includes under:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
/etc/nginx/conf.d/users/username/domainname/

After creating the appropriate include, run:

/usr/local/cpanel/scripts/ea-nginx

The exact include filename and directives must match the existing cPanel-generated server block and the application’s needs. Do not replace the entire generated configuration blindly; a conflicting server block, duplicate server_name, or invalid directive can make NGINX reject a reload or route requests to the wrong domain.

Static directory and application proxy are different configurations

Question Document-root setup Reverse-proxy setup
Where does content come from? Files beneath the configured directory. A running application process, usually reached on a local port or socket.
Primary configuration Domain/virtual host plus root or hosting-panel document root. Proxy directives such as proxy_pass or the hosting platform’s app deployment settings.
Typical entry point index.html, PHP entry file, or another file handled by the server. The application’s listening process and route handling.
Common mistake DNS is correct but the hostname uses the parent domain’s root because sharing was left enabled. Entering a filesystem directory when the app requires proxying, or proxying while expecting NGINX to serve static files directly.

Choose one serving mode for the hostname. cPanel describes the rule plainly: “A domain serves content either as a document root of files or as a proxy to a web app, but never both at once.”

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify the setup in the right order

  1. Check the file: Confirm the target directory contains the expected entry file and that its permissions allow the web server to read it.
  2. Check DNS: Resolve the subdomain from a client or DNS diagnostic tool and confirm that it returns the intended public IP, not an old address or a different service.
  3. Check the hostname: Request the exact configured name. Test the bare subdomain and any separate www name independently.
  4. Check the response: A successful test should return the expected page, not the parent domain’s homepage, a default NGINX page, or an application error.
  5. Check HTTPS: Once HTTP routing works, verify that the certificate covers the subdomain and that HTTPS uses the same intended virtual host.

Testing with a temporary, distinctive index.html makes it easy to tell whether the request reached the new directory. Remove or replace that file after verification.

Troubleshooting: symptom to likely cause

Symptom Likely cause What to check
DNS lookup returns no address No A record, wrong record name, or the record was edited outside the authoritative zone. Confirm the authoritative provider, record name, target IP, and current TTL.
The parent domain’s site appears The subdomain shares the parent document root, or another virtual host answers first. In cPanel, clear Share document root. In NGINX, check for an exact server_name and duplicate or earlier server blocks.
Default NGINX page appears The request reached the server but not the intended server block. Verify the hostname spelling, enabled configuration, reload status, and server-block order.
404 for a file that exists The configured root is wrong, the URL path does not match the filename, or a routing rule changes the request. Compare the document-root path with the actual file location and inspect the access/error logs.
403 Forbidden The directory or file is not readable, or directory listing is disabled and no index file exists. Check ownership, permissions, parent-directory traversal, and the presence of an entry file.
Changes work locally but not elsewhere Cached DNS data is still being used. Check the record from another resolver or network and allow time based on the record’s TTL.
NGINX will not reload Syntax error, conflicting directive, or malformed per-domain include. Run the configuration test, correct the reported file and line, then reload and inspect the error log.
HTTP works but HTTPS fails The certificate does not include the subdomain or HTTPS uses a different virtual host. Install or issue a certificate for the exact hostname and verify the TLS server block.

Choosing a hosting approach

Before committing to a provider or plan, confirm these capabilities rather than assuming every shared account behaves the same way:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Capability Why it matters Question to ask
Separate document roots Determines whether the subdomain can have its own directory. Can I disable shared document root and choose a custom path?
DNS management Determines where the A record must be created or changed. Is DNS managed in this account, or at an external authoritative provider?
Web-server access Controls whether you can add NGINX or Apache virtual-host settings. Can I add per-domain configuration, or must I use the panel’s defaults?
Application proxy support Prevents confusing a directory mapping with deployment of a running app. Does the platform offer a reverse-proxy mode, and how is it configured?
SSL coverage Ensures the new hostname works over HTTPS. Will certificates automatically include newly created subdomains, or must I request one?

Operational and security checks

  • Keep the document root limited to files intended for public access. Do not place backups, environment files, private keys, or source archives beneath a web-served directory.
  • Use least-privilege ownership and permissions so the web server can read required files without granting unnecessary write access.
  • Decide whether the subdomain should redirect HTTP to HTTPS, and configure that redirect only after the HTTPS virtual host and certificate are working.
  • Review redirects and application configuration for hard-coded parent-domain URLs; a copied site can otherwise send visitors back to the main domain.
  • Keep a record of the DNS target, document-root path, and hostname spelling so future changes do not accidentally point the subdomain at an old server.

Quick decision checklist

  1. Is the subdomain’s A record at the authoritative DNS provider?
  2. Does that record point to the server containing the intended directory?
  3. Does the hosting panel or NGINX configuration match the exact hostname?
  4. Is the document root separate from the parent domain when separation is required?
  5. Does the target directory exist, have readable permissions, and contain the expected entry file?
  6. Are you serving static files rather than mistakenly configuring a proxy, or vice versa?
  7. Does HTTPS have a certificate and virtual-host configuration for the subdomain?

If all seven answers are yes, the subdomain should serve the selected directory; any remaining failure is usually isolated by checking DNS resolution, the active virtual-host configuration, and the server’s error log 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 quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

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.