jump to another section | Index |
Using subdomains is a way of organizing the sections of your site to present them in a more attractive manner.
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:
The user accesses your subdomain, and is redirected to the real directory.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^testing.(your domain).com$
RewriteRule .* http://www.(your domain).com/testing/ [r]
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.
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.