Posted on Leave a comment

Domain mapping on website subfolders

Here are three main ways you can map different domains to subfolders:


🔹 1️⃣ Method: Domain Mapping to Subfolders (Using .htaccess or Nginx)

If you want example1.com to show maindomain.com/folder1 and example2.com to show maindomain.com/folder2, you can use .htaccess (for Apache servers) or Nginx rules.

🛠 How to Set It Up (Apache / .htaccess Method)

  1. Open your .htaccess file (located in the public_html folder).
  2. Add this rule at the top: RewriteEngine On # Redirect example1.com to maindomain.com/folder1 RewriteCond %{HTTP_HOST} ^example1\.com$ [NC] RewriteRule ^(.*)$ /folder1/$1 [L] # Redirect example2.com to maindomain.com/folder2 RewriteCond %{HTTP_HOST} ^example2\.com$ [NC] RewriteRule ^(.*)$ /folder2/$1 [L]
  3. Save the file and clear your cache.

📌 Example:

  • Visiting example1.com will show maindomain.com/folder1 but keep example1.com in the URL bar.
  • Visiting example2.com will show maindomain.com/folder2 but keep example2.com in the URL bar.

Best for: Multi-business sites, landing pages, or brand-specific pages.


🔹 2️⃣ Method: Addon Domains with Subfolder Document Root

Many cPanel-based hosts allow you to map a domain directly to a subfolder.

🛠 How to Set It Up in cPanel

  1. Log in to cPanel.
  2. Go to Domains → Addon Domains.
  3. Add a new domain (example1.com).
  4. Set the document root to /public_html/folder1.
  5. Repeat for additional domains (example2.com → /public_html/folder2).

📌 Example:

  • example1.com loads content from maindomain.com/folder1.
  • example2.com loads content from maindomain.com/folder2.

Best for: Hosting multiple separate sites under one hosting account.


🔹 3️⃣ Method: WordPress Multisite (For WordPress Websites)

If you’re using WordPress, you can use Multisite + Domain Mapping to map different domains to different subfolder-based subsites.

🛠 How to Set It Up

  1. Enable Multisite in wp-config.php: define('WP_ALLOW_MULTISITE', true);
  2. Set up Multisite (Subfolder Mode) in WordPress.
  3. Install a domain mapping plugin like:
  4. Add new sites (e.g., maindomain.com/folder1 and maindomain.com/folder2).
  5. Map example1.commaindomain.com/folder1.
  6. Map example2.commaindomain.com/folder2.

📌 Example:

  • example1.com shows content from maindomain.com/folder1 but keeps example1.com in the URL.
  • example2.com shows content from maindomain.com/folder2.

Best for: Running multiple sites from one WordPress installation.


🔹 Which Method Should You Use?

ScenarioBest Method
Show different subfolders under unique domains.htaccess redirects
Map different domains to subfolders (static sites)cPanel Addon Domains
WordPress sites needing domain mappingWordPress Multisite

💡 Need Help?

Let me know which setup you’re using, and I can guide you step by step! 🚀😃

Leave a Reply