sub domain problem ??

OK not used this feature in siteworx but i created a sub domain, which added a dns entry as example:-
my.domain.net cname domain.net
i understand that no a record is needed, now i can access either the subdomain or main domain by using http://my.domain.net or http://domain.net but when trying to access by using
http://www.my.domain.net or http://www.domain.net it redirects to another totally different domain.
I do have 2 domains setup with separate siteworx accounts which use the same ip but not had this problem with using the http://www up until i added the sub domain so i am not sure whats changed.

Where would i look for a problem as it appears that domain with the subdomain is being redirected to my other domain.

Thank you

Currently, the “www.” doesn’t automatically get added to subdomains. The problem has to do with the Rewrite rules we use for subdomains in the vhost conf file. You’ll need to make sure “www.sub.domain.com” is added in DNS and is resolving, then edit /etc/httpd/conf.d/domain.com.conf (where domain.com is your domain) and replace the text between “#subdomain logic” and “#end subdomain logic” with the following:


  RewriteEngine On
  RewriteOptions inherit
  RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
  RewriteCond %{HTTP_HOST} !^domain\.com [NC]
  RewriteCond %{HTTP_HOST} ^([A-Z0-9a-z-]+)\.domain\.com [NC]
  RewriteCond %{DOCUMENT_ROOT}/%1 -d
  RewriteRule ^(.+) %{HTTP_HOST}/$1 [C]
  RewriteRule ^([0-9A-Za-z-]+)\.domain\.com/?(.*)$ %{DOCUMENT_ROOT}/$1/$2 [L]

  RewriteCond %{HTTP_HOST} ^www\.([A-Z0-9a-z-]+)\.domain\.com [NC]
  RewriteCond %{DOCUMENT_ROOT}/%1 -d
  RewriteRule ^(.+) %{HTTP_HOST}/$1 [C]
  RewriteRule ^www\.([0-9A-Za-z-]+)\.domain\.com/?(.*)$ %{DOCUMENT_ROOT}/$1/$2 [L]

Again, domain.com should be replaced with your domain. Also, make sure that the #subdomain logic" and “#end subdomain logic” comments are still in there.
Edit: You’ll also need to make sure the “www.sub.domain.com” is listed as a ServerAlias directive.

Restart apache, and once the www.sub domain resolves, it should work.

Socheat

i changed the code and added dns and www was resolving but on the sub domain still resolving to the wrong domain.
www.sub.domain.net was resolving to www.domain.info my other totally different domain account.

checking /etc/httpd/conf.d/domain.net.conf
i noticed that this line was different to my other domain.com.conf

ServerAlias sub.domain.net

my others had

[SIZE=1]ServerAlias www.domain.biz ftp.domain.biz mail.domain.biz[/SIZE]
[SIZE=1][/SIZE]
[SIZE=1]after adding the missing domain alias mail & ftp and www.sub.domain.net it all worked again with no redirection on the sub domain part.[/SIZE]
[SIZE=1][/SIZE]
[SIZE=1]was this correct or wrong ? [/SIZE]
[SIZE=1][/SIZE]
[SIZE=1]thank you for your reply[/SIZE]
[SIZE=1][/SIZE]
[SIZE=1]
[/SIZE]

Sorry, bear, I forgot to mention the part about the serveralias directive. I’ve edited my original post.

Socheat

ahh i got that part right then.
all working as it should be now.

thanks for your help appreciated.

Now we must change every config if we will enable it. Is it possible that is works default when i use http://www.mysub.domain.com ?

If yes, how can i fix that :slight_smile:

[QUOTE=daveyw;11561]Now we must change every config if we will enable it. Is it possible that is works default when i use http://www.mysub.domain.com ?

If yes, how can i fix that :)[/QUOTE]

You can edit /home/interworx/etc/vhost-base.conf . It won’t help with existing domains though.

Thanks.

Finnaly it works now! :slight_smile:

[quote=IWorx-Socheat;10543]Currently, the “www.” doesn’t automatically get added to subdomains…
Edit: You’ll also need to make sure the “www.sub.domain.com” is listed as a ServerAlias directive.

Restart apache, and once the www.sub domain resolves, it should work.

Socheat[/quote]
We’re trying to accomplish the same thing.

Apologies if this is an elementary question but when you mention “resolving” do you mean that we will have to wait for the same amount of time as when we were originally relocating the TLD?

Thanks,
Stretchr