ForumZCLub
12-Aug-2006, 05:37 PM
About the script
Subdomains is a PHP script that adds numerous sub domains to your website. When the script has been installed, all you need to do to create a new sub domain is a make a new directory. I.e., if you create the directory http://yoursite.com/newdir then the following sub domain will automatically be added: http://newdir.yoursite.com.
Features
No need to edit any files when you want a new sub domain -- whenever you create a new directory it will automatically function as a sub domain.
Works even if the visitor enters "www." in front of the URL: http://www.dir.yoursite.com and http://dir.yoursite.com will both redirect the visitor to http://yoursite.com/dir.
Case insensitive: http://Dir.YourSite.com, http://DIR.YOURSITE.COM, and http://dir.yoursite.com will all redirect the visitor to http://yoursite.com/dir.
Can be used with or without frames. If you use frames, the location bar in the browser will not change -- i.e., if the visitor enters http://dir.yoursite.com, the location bar will still show this URL when the visitor has been redirected to the new location (http://yoursite.com/dir). If you decide not to use frames, the location bar will change from http://dir.yoursite.com to http://yoursite.com/dir.
Requirements
Before you get too excited, you should know that only a minority of all web hosts meet the requirements of this script. To use Subdomains, you need a web site account with the following features:
Your own domain, i.e. yoursite.com.
Wildcarded DNS. The script will not function without this feature. To check if your web host offers wildcarded DNS, you can perform the following test: Start your browser, pick a random word (i.e. "asdf"), and enter your domain name with the random word in front of it like this: asdf.yoursite.com. If you can see the front page of your web site in your browser now, your web host offers wildcarded DNS. However, if the browser response is something like "unable to locate the server asdf.yoursite.com", then your web host does not offer wildcarded DNS, and you cannot use Subdomains (unless, of course, you move to a server that offers this feature).
PHP (version 3 or later). Ask your web hosting company if you don't know if they offer PHP.
.htaccess. In some cases it is necessary to edit the .htaccess file in order to make the script work. This means that your web host must provide you with the ability to use .htaccess files. If the name of the web server software is Apache, then it is very likely that you can use .htaccess files -- but ask your web hosting company if you are unsure.
Installing the script
First you need to change the file name of your front page. The front page is the file that visitors to your web site see when they enter http://yoursite.com. The current name of this file is probably "index.html", "index.php", "default.html", or "home.html"
Load the script (index.php) into a plain text editor such as KEdit (Linux) or Notepad (Windows). Edit the variables at the top of the page.
The $domain variable should be set to the name of your domain. Do not include "www.". Do not include any slashes ("/"). Just write the domain name, i.e. "yourdomain.com". The $default_page variable should be set to the file name of the front page of your web site. I.e., if your front page is located at http://yourdomain.com/welcome.html, you should write "welcome.html" here. The $use_frames variable: If you want to use frames, write "yes" -- otherwise write "no". Have a look at the features section of this README file and the FAQ if you don't understand the difference between redirection using frames and redirection without using frames.
Use a FTP program to upload the index.php file to your web site account. The file should be placed in the document root (this means that you should be able to call the file by pointing your browser to http://yoursite.com/index.php). You don't need to chmod the script since it is not a CGI script.
Now you can try it out. If it works, you're done. If it doesn't work, check the FAQ.
When you want to create a new sub domain, just make a directory in your document root (i.e. http://yoursite.com/newdir). This will automatically work as a sub domain (http://newdir.yoursite.com). Remember that the name of the directory cannot include CAPITAL LETTERS. If you create a directory named "Newdir", the sub domain thing won't work. If you create a directory called "newdir", it will work.
Subdomains is a PHP script that adds numerous sub domains to your website. When the script has been installed, all you need to do to create a new sub domain is a make a new directory. I.e., if you create the directory http://yoursite.com/newdir then the following sub domain will automatically be added: http://newdir.yoursite.com.
Features
No need to edit any files when you want a new sub domain -- whenever you create a new directory it will automatically function as a sub domain.
Works even if the visitor enters "www." in front of the URL: http://www.dir.yoursite.com and http://dir.yoursite.com will both redirect the visitor to http://yoursite.com/dir.
Case insensitive: http://Dir.YourSite.com, http://DIR.YOURSITE.COM, and http://dir.yoursite.com will all redirect the visitor to http://yoursite.com/dir.
Can be used with or without frames. If you use frames, the location bar in the browser will not change -- i.e., if the visitor enters http://dir.yoursite.com, the location bar will still show this URL when the visitor has been redirected to the new location (http://yoursite.com/dir). If you decide not to use frames, the location bar will change from http://dir.yoursite.com to http://yoursite.com/dir.
Requirements
Before you get too excited, you should know that only a minority of all web hosts meet the requirements of this script. To use Subdomains, you need a web site account with the following features:
Your own domain, i.e. yoursite.com.
Wildcarded DNS. The script will not function without this feature. To check if your web host offers wildcarded DNS, you can perform the following test: Start your browser, pick a random word (i.e. "asdf"), and enter your domain name with the random word in front of it like this: asdf.yoursite.com. If you can see the front page of your web site in your browser now, your web host offers wildcarded DNS. However, if the browser response is something like "unable to locate the server asdf.yoursite.com", then your web host does not offer wildcarded DNS, and you cannot use Subdomains (unless, of course, you move to a server that offers this feature).
PHP (version 3 or later). Ask your web hosting company if you don't know if they offer PHP.
.htaccess. In some cases it is necessary to edit the .htaccess file in order to make the script work. This means that your web host must provide you with the ability to use .htaccess files. If the name of the web server software is Apache, then it is very likely that you can use .htaccess files -- but ask your web hosting company if you are unsure.
Installing the script
First you need to change the file name of your front page. The front page is the file that visitors to your web site see when they enter http://yoursite.com. The current name of this file is probably "index.html", "index.php", "default.html", or "home.html"
Load the script (index.php) into a plain text editor such as KEdit (Linux) or Notepad (Windows). Edit the variables at the top of the page.
The $domain variable should be set to the name of your domain. Do not include "www.". Do not include any slashes ("/"). Just write the domain name, i.e. "yourdomain.com". The $default_page variable should be set to the file name of the front page of your web site. I.e., if your front page is located at http://yourdomain.com/welcome.html, you should write "welcome.html" here. The $use_frames variable: If you want to use frames, write "yes" -- otherwise write "no". Have a look at the features section of this README file and the FAQ if you don't understand the difference between redirection using frames and redirection without using frames.
Use a FTP program to upload the index.php file to your web site account. The file should be placed in the document root (this means that you should be able to call the file by pointing your browser to http://yoursite.com/index.php). You don't need to chmod the script since it is not a CGI script.
Now you can try it out. If it works, you're done. If it doesn't work, check the FAQ.
When you want to create a new sub domain, just make a directory in your document root (i.e. http://yoursite.com/newdir). This will automatically work as a sub domain (http://newdir.yoursite.com). Remember that the name of the directory cannot include CAPITAL LETTERS. If you create a directory named "Newdir", the sub domain thing won't work. If you create a directory called "newdir", it will work.