Htaccess to manage multiple domains

Any one here who can help in htaccess to manage multiple domains.
I am now using shared hosting and have the main domain and several other domains as sub-folders. The organization is like this

public_html (https:// www . maindomain . com)
1st domain (http:// www.1domain .com)
2nd domain (http:// www. 2domain .com)

Each one of those domains should appear to be separate domains
when i open 1st domain its opening like this :–>
http:// maindomain . com /1domain .com
Currently code in .htaccess is

# Always use https for secure connections
# Replace 'www. maindomain .com' with your domain name
# (as it appears on your SSL certificate)
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www. main domain .com/$1 [R=301,L]

and Google analytic code
P.S main domain should be open with https:// www
and other are not ssl domain so they should open with http:// www
Thank’s in advance


From your post, I’d have to guess that you’ve misconfigured your cPanel Addon domains (NOT subdomains - although cPanel does this for you automatically).

Correctly configured: is the MAIN domain (of the account) with the DocumentRoot located at public_html

  • is an Addon domain with the DocumentRoot located at public_html/1domain
  • is an Addon domain with the DocumentRoot located at public_html/2domain

That will leave maindomain to be accessed via your SSL and the Addon domains via http and their own domain (they can also be accessed via https as a subdomain of maindomain so, if you don’t want this, be sure to add mod_rewrite code in the subdomain DocumentRoot folders to redirect to