b r a y d e n . o r g / Software

/ WebHome / NetApps / DomainPointing

This Web


WebHome  
Topic List  
Web Statistics 

All Webs


Books
Main
Random
Software
TWiki  

brayden.org


Home
Monthly Digest
Today's Links
Resumé
Reading List
Books RSS
Random RSS
Software RSS

Other


Dale's Blog

currently-reading
TextDrive

Creating A Subdomain (subdomain.yourdomain.com)

by Sophie (aka TheBomb )

(Big thanks to TheUberMonkey who found this solution)

This tutorial comes in 2 parts:

  1. Creating the CNAME
  2. Editing your .htaccess file

1. Creating the CNAME

    1. Log in to https://ops.powweb.com
    2. Click on 'Packages' then in the list of packages, click on 'DNS'
    3. In the DNS screen, click on the link at the bottom that says 'Add CNAME'
    4. In the 'Alias' field, type in the name of your subdomain (i.e. if you want your subdomain to be chat.yourdomain.com then type in 'chat'). In the 'Hostname' field, type in 'yourdomain.com.' where yourdomain is the name of your domain. NOTE: There must be a period at the end!! Click 'Save'. The CNAME will become active when the name servers are reloaded (at noon and midnight daily).
2. Editing your .htaccess file
    1. If you already have a .htaccess file open it, otherwise create a new file called '.htaccess'
    2. Assuming your domain name is www.blah.com and you want a subdomain chat.blah.com that points to a folder in your htdocs/ folder called chat/ add these lines to your .htaccess file:
RewriteEngine On 
Options +FollowSymlinks 
RewriteBase / 
RewriteCond %{HTTP_HOST} chat.blah.com 
RewriteCond %{REQUEST_URI} !chat/ 
RewriteRule ^(.*)$ chat/$1 [L]
Note: If you want the subdomain chat.blah.com to point to a folder in your htdocs called mychatfolder/ then you would add these lines:
RewriteEngine On 
Options +FollowSymlinks 
RewriteBase / 
RewriteCond %{HTTP_HOST} chat.blah.com 
RewriteCond %{REQUEST_URI} !mychatfolder/ 
RewriteRule ^(.*)$ mychatfolder/$1 [L]
3. Save the file and upload it to your htdocs/ folder.

Multiple Subdomains

1. Create the CNAME for the second subdomain as in part 1 above.

2. Open your .htaccess file. Repeat the last 3 lines, i.e.

RewriteCond %{HTTP_HOST} secondsubdomain.blah.com 
RewriteCond %{REQUEST_URI} !folder/ 
RewriteRule ^(.*)$ folder/$1 [L]
3. Save the file and upload it to your htdocs folder.

*Pointing your subdomain to a file (not a directory) *

Use these lines instead:

RewriteEngine On 
Options +FollowSymlinks 
RewriteBase / 
RewriteCond %{HTTP_HOST} chat.blah.com 
RewriteCond %{REQUEST_URI} !chatfolder/filename.cgi 
RewriteRule ^(.*)$ chatfolder/filename.cgi$1 [L]

This will allow you to point to any filename, be it .html, .php. cgi, .pl, etc.

 
 
Current Rev: r1.2 - 25 Jun 2003 - 17:34 GMT - DaleBrayden, Revision History:Diffs | r1.2 | > | r1.1
© 2003-2011 by the contributing authors.