Skip to content

Instantly share code, notes, and snippets.

@imseyed
Last active July 6, 2025 14:31
Show Gist options
  • Save imseyed/8ebe2b2c49425b8ee1dbf36125cb3629 to your computer and use it in GitHub Desktop.
Save imseyed/8ebe2b2c49425b8ee1dbf36125cb3629 to your computer and use it in GitHub Desktop.
Bypassing Addon Domain Limits on Shared Hosting

Apache .htaccess for Shared Hosting Setup (Alias Domain Instead of Addon Domain)

This .htaccess file is useful for shared hosting environments where the number of Addon Domains is limited.

πŸ”§ Use Case

Instead of configuring real Addon Domains in cPanel or your hosting panel, you can simulate them using folders and Apache rewrite rules.


πŸ“ Folder Structure

Place this .htaccess file inside your public_html directory. Then, create a folder for each domain you want to simulate. Use folder names that are different from the domain name for clarity:

public_html/
β”œβ”€β”€ .htaccess
β”œβ”€β”€ foo_site/
β”œβ”€β”€ bar_site/

Point your domains (e.g., foo.com and bar.net) to the same public_html directory. Apache will internally redirect each request to the correct subfolder based on the requested domain.

πŸ§ͺ Example Domains

  • foo.com will load files from the folder public_html/foo_site
  • bar.net will load files from the folder public_html/bar_site

πŸ“ .htaccess Code

RewriteEngine On

# Match domain: foo.com
RewriteCond %{HTTP_HOST} ^foo.com$ [NC]
RewriteRule ^(.*)$ /foo_site/$1 [L,QSA]

# Match domain: bar.net
RewriteCond %{HTTP_HOST} ^bar.net$ [NC]
RewriteRule ^(.*)$ /bar_site/$1 [L,QSA]

βœ… Notes

  • Make sure mod_rewrite is enabled on your Apache server.
  • Use [NC] for case-insensitive domain matching.
  • [L,QSA] ensures query strings are preserved and no further rules are processed.
  • You can add as many domains/folders as needed by copying the RewriteCond + RewriteRule blocks.

This approach effectively mimics Addon Domains using simple rewrite rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment