The main difference is that public_html is the folder on a web server that holds the files your website serves to visitors, while www is a subdomain (usually www.example.com) that points to that same folder or to the server’s root. In practice, www is a URL prefix, and public_html is a directory path — they operate at different layers of web hosting, but they are often confused because both appear in website management tools.
Background: How Web Hosting Organizes Files
When you sign up for shared hosting, the company gives you a server account with a directory structure. The public_html folder (sometimes called htdocs on Apache, or www on some older setups) is the document root for your domain. Anything you put inside it — HTML files, images, JavaScript, CSS — is accessible via your domain name. For example, if you upload about.html to public_html, visitors can reach it at https://example.com/about.html.
The www in a URL is a hostname or subdomain. It is a convention from the early web, when administrators used www to distinguish the web server from other services like FTP or mail. Today, www.example.com and example.com are usually configured to serve the same content — the server simply maps both hostnames to the same document root (public_html).
How the Two Work Together
Here’s the key: www is not a folder. It’s a DNS record. When someone types www.example.com, their browser asks the DNS system for the IP address associated with that hostname. The web server receives the request, looks at the Host header, and decides which virtual host to use. That virtual host points to a directory — often public_html.
So the flow is:
- Browser requests
http://www.example.com - DNS resolves
wwwto the server’s IP - Server sees the hostname and loads the virtual host config
- The config sets the document root to
/home/username/public_html - Server serves files from that folder
If you have multiple domains, each has its own public_html folder (e.g., public_html for the primary, public_html2 for an addon domain). The www prefix is just a label — it doesn’t change which folder is used.
Common Confusion: When “www” Appears as a Folder
Some hosting control panels (like cPanel) show a folder named www in the file manager. This is usually a symlink (a shortcut) to public_html. If you upload a file to www, it appears in public_html because they point to the same location. On older servers or certain setups (like some Nginx configurations), the document root might literally be named www. But in modern shared hosting, public_html is the standard.
Why the confusion? Because early web servers often used htdocs or www as the default web folder. When hosting companies standardized on public_html, they kept a www symlink for backward compatibility. So if you see both, they are the same place.
Which One Should You Use?
For uploading website files, always use public_html (or the document root your host specifies). It is the actual directory. The www symlink works too, but some FTP clients or file managers may not follow symlinks correctly, causing confusion. Stick to public_html for consistency.
For your domain’s URL, decide whether to use www or non-www and stick with it. Set up a 301 redirect from one to the other to avoid duplicate content issues for SEO. Most hosts let you choose a preferred domain in cPanel or through a redirect rule in .htaccess.
Common Problems and Misconceptions
- “I uploaded to www but nothing shows” — If your host uses a separate
wwwfolder (not a symlink), you might have uploaded to the wrong place. Check your file manager: ifwwwis a folder with a different icon or a shortcut arrow, it’s a link. If it’s a real folder, your document root might be set topublic_html— use that instead. - “www.example.com works but example.com doesn’t” — This is a DNS or virtual host issue. The
wwwsubdomain has an A record, but the bare domain doesn’t. Add an A record for the root domain or set up a redirect. - “I deleted public_html by accident” — On some hosts, deleting
public_htmlcan break your site. You may need to recreate it and set permissions to 755. But ifwwwis a symlink, it might break too. Always back up before deleting. - “My .htaccess in public_html affects www” — Yes, because
wwwpoints to the same folder, so any rules apply to both. This is usually what you want.
Security and Permissions
Files in public_html are world-readable by default, which is necessary for the web server to serve them. Directories should be set to 755, files to 644. The www symlink, if present, inherits the permissions of its target. Never put sensitive files (like database credentials) inside public_html — place them outside the document root, where they aren’t accessible via the web.
If you use www as a separate folder (not a symlink), it could expose a second copy of your site, which might be outdated or insecure. Always check that both www and public_html point to the same content, or disable the www folder if you don’t need it.
Alternatives and Modern Practices
Some hosting environments use different names:
- htdocs — common on XAMPP and some Apache installs
- web — used by some Node.js or Python hosts
- html — used by some Nginx setups
- /var/www/html — the default for many Linux servers, where
wwwis a parent directory, not a symlink
In modern cloud hosting (like AWS or Heroku), there is often no public_html at all — the server runs code directly. But for traditional shared hosting, public_html remains the standard. The www prefix is purely a URL choice; you can even remove it entirely and use only the bare domain.
Frequently Asked Questions
Is www a folder on the server?
No, www is a subdomain in the URL. On some servers, a folder named www exists as a symlink to public_html, but it’s not a separate directory. The actual files live in public_html.
Can I upload files to www instead of public_html?
If www is a symlink, yes — files will appear in public_html. But if it’s a real folder, the server won’t serve it unless the document root points there. Always check your hosting documentation.
Why does my website show both www and non-www versions?
That happens when both hostnames resolve to the same server and the server serves the same content without redirecting. To avoid duplicate content, set a 301 redirect from one to the other using .htaccess or your hosting control panel.
What is the document root?
The document root is the folder that the web server uses to find files for a given domain. For most shared hosting, it’s public_html. You can find it in your control panel or by asking your host.
Does deleting public_html delete my website?
Yes, if you delete the contents, your site will be gone. If you delete the folder itself, the server may throw an error. Always back up before making changes.
Can I rename public_html to something else?
Not easily — the server configuration expects that name. You could change the document root in the virtual host settings, but that’s risky and unnecessary. Keep the default.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Disable Autocorrect on iPhone or iPad: Quick Guide
- Custom Keyboard Shortcuts on Windows 11 & macOS
- Restore Windows 11 Display Scaling to Recommended
- Semiconductor Cycle: How Investors Track It0.0
- Microsoft Store Error 0x80073d12: Fixes That Work
- View Notification Count on iPhone: Full Guide