Help - Search - Members - Calendar
Full Version: HowTo: Point domains to subdomains
The Planet Forums > Control Panels > Ensim > Ensim HOWTOs
clanscc
One of my friends asked me if it was possible to have another domain point to subdomain.maindomain.com. I wasn't sure at first but I figured out a way to have a domain point to another subdomain on an ensim system.

First in mind you must have the domain you want to point to the subdomain point to your dns.

Next you will need to add DNS records for the domain.

Login to the Administrator Panel on Ensim and click on the DNS link under services.

Click on the link that says "Zone List"

Then click on Add a New Zone.

Put in the domain name that you need to create the zone for.

Once you add the zone, you should see two records already with your nameservers in both.

Next, add two A records one with www in front of the domain and one with nothing in front of the domain and put in your IP number of your server.

Next, find the path where the subdomain exists. For example: radio.maindomain.com maybe located in /home/virtual/maindomain.com/var/www/html/radio or /home/virtual/maindomain.com/var/subdomains

Make sure you note the site/admin number. You can look up the number by simply doing ls -la in the directory of the domain /home/virtual/maindomain.com/var/www/html

Once that is done.. cd to /etc/httpd/conf/virtual

View the site# (The # is what you noted before)

I copied this information in the site# to notepad and edited:

Make the following changes:

ServerName: Put in the domain that you want it point to the subdomain
(For an example: site1's main domain is www.lala.com) You want to insert the new domain in place of that. - www.newdomain.com

ServerAlias: Put in the new domain with out the www. infront.

DocumentRoot: Change this to the path of the subdomain. (Example: /home/virtual/maindomain.com/var/www/html/radio, /home/virtual/maindomain.com/var/subdomains/radio)

The first two tags you will need to replace the path with your subdomain path.

Example:
Example:

Then at SetEnv SITE_HTMLROOT:
Change it to /home/virtual/site#/fst/var/www/html/radio or it can be
/home/virtual/site#/fst/var/subdomains/radio (depending how your subdomains are setup)

Then save this document in the /etc/httpd/conf/virtual directory with whatever file name you want on the server and restart apache and your done!
ntburchf
Anyone got something like this to work with pro x
CODE
# apache configuration



<VirtualHost 209.1.1.1:80>



    ServerName www.some-domain.com

    ServerAlias some-domain.com

    ServerAdmin admin@some-domian.com

    DocumentRoot /home/virtual/site42/fst/var/www/sub_domains/some-domain

    RewriteEngine on

    suexecUserGroup admin42 admin42



    RedirectMatch ^/admin/?$ [url="https://209.1.1.1:19638/siteadmin/?ocw_login_domain=some-domain.com"]https://209.1.1.1:19638/siteadmin/?ocw_logi...some-domain.com[/url]

    RedirectMatch ^/user/?$ [url="https://209.1.1.1:19638/siteuser/?ocw_login_domain=some-domain.com"]https://209.1.1.1:19638/siteuser/?ocw_login...some-domain.com[/url]



    RewriteRule ^/~([^/]+)(.*) /users/$1$2 [PT]

    AliasMatch ^/users/([^/]+)/?(.*) /home/virtual/site42/fst/home/$1/public_html/$2



    <Directory /home/virtual/site42/fst/var/www/sub_domains/some-domain/>

 Allow from all

 AllowOverride All

 Order allow,deny

    </Directory>



    <Directory /home/virtual/site42/fst/var/subdomain/some-domain/>

 Allow from all

 AllowOverride All

 Order allow,deny

    </Directory>



    SetEnv SITE_ROOT /home/virtual/site42/fst

    SetEnv SITE_HTMLROOT /home/virtual/site42/fst/var/www/sub_domains/some-domain



       # Disable the ability to follow symlinks;

       # users should use SymlinksIfOwnerMatch instead

       <Directory /home/virtual/site42/fst>

         Options -FollowSymlinks +SymlinksIfOwnerMatch

       </Directory>

       <IfModule mod_php4.c>

               # Don't allow mod_php

               php_admin_flag engine off

       </IfModule>

       <IfModule sapi_apache2.c>

               php_admin_flag engine off

       </IfModule>

       Action php-script /interpreters/php-script

       AddHandler php-script .php .php4 .php3



       <Directory /home/virtual/site42/fst/var/www/interpreters>

               Options ExecCGI

               SetHandler cgi-script

       </Directory>

       Alias /interpreters/ /home/virtual/site42/fst/var/www/interpreters/



    Include /etc/httpd/conf/site42



</VirtualHost>


I can get it to load the sub-domain with those redirects but trying to do any php get's the 500 internal error
CODE
[Sun Dec 24 03:56:56 2006] [error] [client 72.1.19.1] Premature end of script headers: php-script


What's missing here that's stopping php from loading?

Thanks!
Penguin
There is a far easier way, especially as editing the apache config files you will find when you perform an upgrade Ensim overwrites them. Just locate your subdomain in /var/www/html/subdomainn and use the following:

Firstly, alias the domain to the main account as you would normally to map additional domains. You then need to create a .htaccess file with the following in it which you need to put in your website root folder (/var/www/html)

The following code is an example:

RewriteEngine On
RewriteCond %{HTTP_HOST} alias.co.uk$ [NC]
RewriteCond %{REQUEST_URI} !^/aliasdir/.*$
RewriteRule ^(.*)$ /aliasdir/$1

alias.co.uk is the additional aliased domain
aliasdir is the directory in your webspace where you want the aliased domain's website to be directed to.

When you then visit http://www.alias.co.uk the server redirects your visitors to http://www.original.co.uk/aliasdir/ but still shows www.alias.co.uk in the address bar.

As another example, we have a domain called domain2.com which is aliased to the hosting account of domain.com We want domain2.com to point to http://domain.com/other/domain2. Youi would then use this code:

RewriteEngine On
RewriteCond %{HTTP_HOST} domain2.com$ [NC]
RewriteCond %{REQUEST_URI} !^/other/domain2/.*$
RewriteRule ^(.*)$ /other/domain2/$1
ntburchf
Thanks!!

I'll try that, as it looks 1000 times easier-
found out where I messed up, when I did chown -R admin42:admin24
I reversed the 24 when it should have been 42 icon_smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.