Category Archives: addon-domain

Preventing primary domain from showing addon domains’ content as its subfolder

I have a primary domain and 5 addons as independent sites. Everything is fine, but when one clicks primary.com/addon1.com, s/he can access irrelevant content over primary website. I want to prevent this.

I am looking for a solution via the htaccess in root of primary, not to edit 5 htaccess files of addons.

Simply, I tried the below code in primary htaccess, but it doesn't work. I tried many other alternatives, but doesn't work. Why? What is wrong with this?

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} (.*)primary\.com$
RewriteRule ^/(addon1|addon2|addon3|addon4|addon5)(.*)$ http://primary.com [R=301,L]
</ifModule>

Redirect Exclusions [on hold]

I have domain.co.za and under that I have a subdomain set up as sub.domain.co.za. I also have an addon domain set up as addon.co.za. I want domain.co.za (with and without www) to redirect to newsite.com. Then sub.domain.co.za and addon.co.za (with or without www) both need to run their respective Wordpress sites already loaded onto them. Also, if possible, domain.co.za/anything should also redirect to newsite.com. (This is for all the google search results I might still have to certain pages). I've probably been through every tutorial on the web, but nothing gives me this specific result I'm looking for. Any help would be greatly appreciated. Even if I can only get addon.co.za to work and domain.co.za to redirect (with and without www).

Thank you for your time.

Add-On Domain Redirects to HTTPS

I have a GoDaddy shared hosting account with one main domain that uses SSL and now an add-on domain that I do not want to use SSL. I would like to redirect non-https to https for the main domain BUT NOT for the add-on domain. Both sites use Wordpress.

To be clear, the main domain should use https, the add-on domain should not use https.

The problem I am experiencing is addondomain.com is redirecting to https://addondomain.com.

I know the problem can be fixed through my .htaccess file, and I have made several attempts, but each one ends with the add-on domain redirecting back to the main domain. Any insight as to what I need to change on my .htaccess file would be very much appreciated!

Here is what my .htaccess file looks like:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Add On Domain IP Address

Do add on domains need a unique ip address or can they point to the same ip address as the main domain and use the .htaccess file to redirect to the subfolder?

Details:

I am trying to host two web applications on a single server. I setup the new domain name as an add on domain to my current server. In the process of getting it to work I replaced the new domain A record ip address with the current domain name ip address on the server thinking that it had to point to the same place.

Now when I type out the full www.domainname.com it just points to the same files as the other web application and if I type only domainname.com it gives me a warning and fatal error about failing to open a required file css_version.php.

I managed to get domainname.com to redirect to the proper add on subfolder using the .htaccess file but www.domainname.com still points to the other web application.

Can I fix this with the .htaccess file or does the domain name need to have a unique ip address for the server to differentiate between the two domains and if so how can I get the unique ip address it had back?

Redirect all requests to index.php except subdomains

I'm using AltoRouter: (http://altorouter.com/) and I modified .htaccess as suggested in the instalation to:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

This is so that index.php can handle all the requests. My problem is that I am using addon domains in cpanel and I am having internal server errors when I try to access one of the domains associated with the addon domain.

Example: My main domain is mainsite.com.

Then I have several sites:

site1.com that cpanel automatically associates with site1.mainsite.com and creates a folder mainsite.com/site1.com. So if I access site1.com I would see in browser site1.com but the content delivered would be the one inside the mainsite.com/site.com folder.

This works if I don't use the .htaccess rule but I need it for routing. If I have that rule I get internal server errors everytime I access site1.com (I assume that it's a conflict between cpanel rules and .htaccess).

How can I modify the rule so that it only affects maindomain and not subdomains? I am assuming that by doing this there would be no conflict and my problem would be solved.

I am really bad at .htaccess and regex but I am willing to learn if needed. I would still appreciate if you could point me to the right direction. (both in the idea and in good websites that can help me understanding this)

add-on domain path without main domain path in URL

In my hosting account on cpanel, I have one main domain for e.g. www.abc.com and one addon domain say xyz.com. The document root of addon domain is home/public_html/xyz.com. So the .htaccess file in root directory of abc.com is the main htaccess file. (no another .htaccess file for addon domain). The problem is xyz.com is automatically redirected to www.abc.com/xyz.com. I have set 301 redirection only for www.abc.com (for non-www to www). I want when I type xyz.com it is redirect as www.xyz.com. not as www.abc.com/xyz.com

.htaccess redirect http to https for only some addon domains

I have a multiple addon domains on my hosting account. I would like to redirect non-https to https for the main domain AND ONLY ONE of the addon domains.

The problem I am experiencing is www.firstaddondomain.com is not redirecting to https://www.firstaddondomain.com. Instead it does not appear to be redirecting at all. It stays at www.firstaddondomain.com.

Note: I do not want to redirect all http to https. I have another addon domain that I do not want redirected to https.

Here is what my .htaccess file looks like:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?maindomain\.com$ [NC]
RewriteRule ^$ https://www.maindomain.com/$1 [R,L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?firstaddondomain\.com$ [NC]
RewriteRule ^$ https://www.firstaddondomain.com/$1 [R,L]

UPDATE: "#"s in original post were a mistake with the post, not the code.

SECOND UPDATE: Thanks for your answer, anubhava. My first addon domain is actually a .org domain, so my updated .htaccess file is slightly different from your answer.

Your solution helped, but I'm still having some trouble.

www.firstaddondomain.org is now redirecting to https://www.firstaddondomain.org which is what I wanted. But secondaddondomain.com is also redirecting to https, but I do not want this second addon domain to redirect to https. I don't have a SSL certertificate for the second addon domain and the user is getting a warning.

I noticed that www.secondaddondomain.com (note the www) is not redirecting to https which is good.

Here is my updated .htaccess file

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?firstaddondomain\.org$ [NC]
RewriteRule ^ https://www.firstaddondomain.org%{REQUEST_URI} [R=302,L,NE]

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?maindomain\.com$ [NC]
RewriteRule ^ https://www.maindomain.com%{REQUEST_URI} [R=302,L,NE]

.htaccess url rewriting for addon domains

I have a web hosting that is running multiple website. Suppose i have xyz.com that is the main website under this other websites are running as addon domains.

Like i have another website that is xyz2.com that is addon domain. There is folder created corresponding to the domain xyz2.com.

Now the problem is i want to add some .htaccess rule there is no rule defined for root website. I want to add rule only for xyz2.com that is addon domain.

i have placed my .htaccess to the folder xyz2.com. here is what i wrote.

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^(www\.)?xyz2.com\.com$ [NC]

RewriteCond %{THE_REQUEST} /find\.php\?source=([^\s&]+)&destination=([^\s&]+) [NC]
RewriteRule ^ %1-%2.html? [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\s]+)-([^\s]+)?.html$ find.php?source=$1&destination=$2 [L,QSA]

This is not working i have searched a lot on google for this problem but no suggestions is working. Please help me to short out this problem.