addon domain redirect messed up

chmod root

Active Member
Oct 18, 2006
28
0
151
Have a main domain setup on the account. Added an addon domain. Want the MAIN domain to redirect to another link within the same main domain.

http://maindomain.com >> http://maindomain.com/folder/index.php

it works, but it causes the addon domain to redirect to that link also. It should now.

I have tried this:

Redirect permanent /index.html http://www.domain.com/addondomainfolder/index.php

It caused the addon and subdomains to redirect as well. This is not normal, as is cpanel not normal.

Anyone know about this?
 

chmod root

Active Member
Oct 18, 2006
28
0
151
addon.com is redirecting to main.domain

I deleted all instances of the addon from /var/cpanel/users, named.conf, httpd.conf, etc. and re-added it fresh. I deleted .htaccess file and redid the MAIN domain redirect via cpanel as

http://main.com to http://main.com/folder/index.php

now the main redirects fine, but addon STILL redircects to main domain???
 

4u123

Well-Known Member
PartnerNOC
Jan 2, 2006
948
29
178
Yep, I think this is normal cpanel behaviour.

If you redirect the primary hosted domain on an account - all the addons also get redirected there.

I guess its just another bug they couldnt be bothered to fix.
 

IceProducts

Registered
May 28, 2006
2
0
151
Does anyone know of a manual way to fix this? I have been searching for weeks trying to figure this out and beating my head endlessly against the wall trying to get this to work properly.

Here is my example:

My shopping cart is currently at http://www.mydomain.com/store/

I want it to be accessible when users go to http://www.mydomain.com/

I have setup a permanent (and tried temporary) redirect (using CPanel) and it works fine. However, every other subdomain also gets redirected to http://www.mydomain.com/store/

For example: http://subdomain.mydomain.com should get its data from http://www.mydomain.com/subdomain but instead it gets redirected to http://www.mydomain.com/store/

I am not sure if this is a "Bug" or not but it sure seems like it. It would be nice if it was fixed but in the mean time I really just need to get this working properly and am capable of editing whatever needs to be manually edited if someone could just point me in the right direction.

I appreciate your help in advance,
IceProducts
 

Stefaans

Well-Known Member
Mar 5, 2002
461
4
318
Vancouver, Canada
Firstly, I feel I should state that the behaviour you are seeing is not a bug. By design, Apache will inherit any settings in .htaccess to sub-directories. Because add-on domains reside in sub-directories of public_html, any redirect settings you make for the account's main domain automatically applies to the add-on domains to.

IMHO, there is a couple of things Cpanel could do differently to make things easier/better:
* Instead of arsing RedirectMatch, use the the mod-rewrite functions instead. With mod_rewrite, one can set rules per domain and thus get the resolution required here. See my example below.
* It would be nice if Cpanel set up add-on domains somewhere in the user's directory outside of the public_html directory, e.g. in public_html_addondomain. That way the main domain and add on domains can be configured independently.

Anyway, back to the problem. IceProducts, the following code in your .htaccess should give the desired result:
Code:
RewriteEngine On
rewritecond %{http_host} mydomain\.com$
rewriteRule !store* http://www.mydomain.com/store/ [R=301,L]
The first line enables mod_rewrite (quite obvious). The second line says that the settings that follow only apply to hosts that end with mydomain.com, e.g. mydomain.com and www.mydomain.com, and hence excludes your add-on domains. The third line checks if the URL includes the word "store", and if it does not, redirects to www.mydomain.com/store. It also sends a 301 response, meaning the document has moved permanently.

I hope this helps ;)