[Home]   i n s t r u c t i o n s
< back to index       Subdomains
 
i n f o
   about us
   technical
   payment
   contact

s e r v i c e s
   packages
   server
   design
   sign up

s u p p o r t
   instructions
   F.A.Q.
   password

m i s c
   resellers
   offers
   free

h o m e

  Using subdomains is a way of organizing the sections of your site to present them in a more attractive manner.

How it works
We use wildcard DNS entries so anything.(your domain).com will go to the same site. The web server is also configured to respond for *.(your domain).com. When anybody makes a request to your site, the web server first checks the .htaccess for any password-protection or rewriting rules. It will see your settings, and if anything matches, it will either redirect or rewrite the address to the one you specify. Everything is automatic, you don't need to notify us to create a subdomain for you.

In these examples, we will assume the subdomain "testing", accessed as http://testing.(your domain).com.

There are two main ways to set them up:

Redirection
The user accesses your subdomain, and is redirected to the real directory.

  • First, create a subdirectory called "testing" inside your "www" directory.
  • Second, edit the .htaccess file in your "www" directory to look like this:
     
    RewriteEngine On 
     
    RewriteCond %{HTTP_HOST} ^testing.(your domain).com$ 
    RewriteRule .* http://www.(your domain).com/testing/ [r] 
    
    

Transparent
The user accesses your subdomain, and sees the contents of the subdirectory as if it were a separate site. This way completely hides the real location of the subdirectory.

  • First, create a subdirectory called "testing" inside your "www" directory.
  • Second, edit the .htaccess file in your "www" directory to look like this:
     
    RewriteEngine On 
     
    RewriteCond %{HTTP_HOST} ^testing.(your domain).com$ 
    RewriteCond %{REQUEST_URI} !^/testing/ 
    RewriteRule (.*) /testing/$1 
    
Please note that when using this method, if you use custom ErrorDocuments you need to copy them into the subdirectory. Also, if you include documents from .shtml files, you must use paths relative to the main web root.

To add more subdomains, add more of the RewriteCond and RewriteRule lines to the end of the .htaccess file.

It is also possible to do the redirection with cgi instead of the .htaccess file. To do this, place the redirection cgi in your "www" directory and name it "nph-index.cgi". It will be the first thing to load, and can then redirect the user to the location you configure.

 

 
TOPICS
getting started
domain registration | mail forwarding | checking mail | uploading your site
basic features
web stats | hit counters | form-to-mail cgi | redirect cgi | autoresponders |
basic mailing lists | advanced mailing lists | search engine submission | frontpage extensions | password protected directory | custom error pages | subdomains
advanced features
cgi scripts | server-side includes | php | mysql |

 
All your hosting dreams come true!
P R O F E S S I O N A L
hkhosting.com
W E B   S E R V I C E S

Copyright © 1999-2003 HK Hosting Ltd. All rights reserved. Terms & Conditions