Terminology used in this page
- Main domain = The primary domain attached to your package.
Example: yoursite.com- Subdomain = Subpart of your site accessed by domain name with prefix.
Example: sub1.yoursite.com- Pointed/serviced domains = Additional domain names attached to your package
(by OPS -> package -> "add pointed domain" or "add serviced domain")
What is it?
Your package can have multiple domain names associated with it.By default, all domain names and subdomains will act like alias of the main domain.In other words, ALL traffic will go to the main /htdocs.Example: http://www.yoursite.com/index,html ==> /www/U/USER/htdocs/index.html http://sub1.yoursite.com/index,html ==> /www/U/USER/htdocs/index.html http://www.pointed.com/index,html ==> /www/U/USER/htdocs/index.html http://sub1.pointed.com/index,html ==> /www/U/USER/htdocs/index.html http://sub2.pointed.com/index,html ==> /www/U/USER/htdocs/index.html http://www.serviced.com/index,html ==> /www/U/USER/htdocs/index.html UsingRewriteRules (commonly known as mod_rewrite) in .htaccess file, you can specify different URL/directory/files to be served.Example: http://www.yoursite.com/index,html ==> /www/U/USER/htdocs/index.html http://sub1.yoursite.com/index,html ==> /www/U/USER/htdocs/sub1.yoursite.com/index.html http://www.pointed.com/index,html ==> /www/U/USER/htdocs/pointed.com/index.html http://sub1.pointed.com/index,html ==> /www/U/USER/htdocs/sub1.pointed.com/index.html http://sub2.pointed.com/index,html ==> /www/U/USER/htdocs/sub2.pointed.com/index.html http://www.serviced.com/index,html ==> /www/U/USER/htdocs/serviced.com/index.html This way, you can use one package for serving multiple websites.
Warning
PowWeb DOES NOT give any assistance or support for using .htaccess.Please do not file a support ticket about this matter.Abusive use of support desk will slow it down and everybody may suffer.Also,PowWeb will ask you to leave if you go over daily/hourly limits, often.This method shouldn't be used by a site with lots of traffic.Rather, you are encouraged to use multiple packages.Using this method (or any other .htaccess based method) may complicate site maintenance.Expect some undesired side effects if you use these.Without "Virtual document root" feature, some script will act badly.However, "Virtual document root" feature has it's own side effect andit does add slight over head, too.Please be aware that you are making a compromise.
Other methods
- DomainManager is a quite easy and powerful tool for setting up and maintaining sub/pointed domain related matters.
Currently, DomainManager does not support Generic .htaccess method explained in this page.Rather, it offers "Traditional .htaccess method".If you plan to have small number of sub/pointed domains, DomainManager can be a good choice.It comes with diagnostic tools and it can handlePowWeb's new easy method subdomain, too.
- Manual setup
You can setup everything manually.There are many Forum posts and resources showing how to do this.http://kb.powweb.com/ shows one way of doing it, but the code is not really good.DomainManager is very useful for manual setup, too.It has .htaccess editor, testing facility, latest log display link, and other features.If you want to have subdomain, and you don't plan to use pointed domains,PowWeb's Easy method subdomain can be a good choice.However, you should know that it's a little difficult to share the files among this method of subdomain and main domain.DomainManager fully support this.
How to?
Before to use ...
Make sure that pointed/serviced domains you intend to use are coming into main domain.If not, follow these steps.
- Register the domain name (with http://registerfly.com/ , PowWeb , ...)
- Choose DNS (ns2.powweb.com & ns3.powweb.com if you don't know how to edit DNS record by yourself.)
- Goto OPS -> Packages and use "Add pointed domain" or "Add serviced domain" form to setup
PowWeb 's configuration. (If you make mistake in this step, you have to ask support to correct it, and it may take time.)- Wait (up to 72 hours) for your DNS record to propagate. Check with "whois" (http://www.whois.sc/ http://www.dnsstuff.com/ ) "dig"
- Finally,
http://newly-registered.com/ should show the same data as http://main-domain.com/ If you already have extratools.php,
- Click "Install/update genht.php"
- When automatic installation is done, click on the link to "run".
- Check the proposed .htaccess if you understand how it works.
- Click on one of "Setup ...." link.
- Create directories for sub/pointed domain you want
- Put some pages in the directories (such as index.html for testing)
- Test the new sub/pointed domains
If you have already a protected directory or you know how to protect,
- Upload or copy&paste this file as genht.php in the protected directory
- Access http://yoursite.com/protecteddir/genht.php
- Check the proposed .htaccess if you understand how it works.
- Click on one of "Setup ...." link.
- Create directories for sub/pointed domain you want
- Put some pages in the directories (such as index.html for testing)
- Test the new sub/pointed domains
If you are totally clueless,
- Login to WebFTP
Access https://webftp.powweb.com/ using parameters you received in welcome mail. If you don't know which FTP server to use, goto OPS->Packages->FTP and you will see Server Hostname ftp0X.powweb.com- Go to htdocs
When the list of directories and files shows up, click on htdocsYou should see You are here: /htdocs at the top of the list.- Make new directory
- Click Make Dir in the upper left side
- Type in the name you can retain, all in lower case without space or other special characters ("zzz" for example).
- Push Make Dir button.
- Go to newly created directory
When the screen updates, click on the new directory you've just created.You should see You are here: /htdocs/newdir at the top of the list.- Copy&Paste extratools.php
- Click Create file in upper left side just under Make dir.
- Open this URL: http://check-these.info/tools/extratools_php.txt in a new tab or window in your browser
- Ctrl-A then Ctrl-C to copy everything. (or Edit menu -> select all, Edit->Copy)
- Return to the Create file subwindow and paste with Ctrl-V
- Type in extratools.php in the filename and push save
- Use extratools.php
- In a new tab/window access http://yoursite.com/newdir/extratools.php
- Click the link to password protect.
- Enter username, password of your choice.
- Install genht.php
After logging in, click on install/update genht.php- Use genht.php for setting up sub/pointed domains
- When installation is done, click Access genht.php or run genht.php.
- Click on "Setup Generic .htaccess method with virtual document root"
- Read the out put, read the way you should create directories.
- Create directories for sub/pointed domains
- With WebFTP, create directories for the sub/pointed domains by:
- Go into /htdocs, just like you did before.
You should see "You are here: /htdocs".- Click "Make dir" button
- Enter the domain name WITHOUT "www" as directory name.
ex. www.abc,com ===> enter "abc.com"ex. sub1.xyz.com ===> enter "sub1.xyz.com"- Hit the "Make dir" button in the form.
- Put files in new directory (such as index.html), and test.
- Go into newly created directory.
You should see "You are here: /htdocs/abc.com", for example.- Use "Crate file" to make index.html for testing.
- Type in some text with the name of domain.
ex. "Test index for abc.com"- Type in the file name of "index.html" (all in lower case)
- Save the file and confirm.
- Test sub/pointed domains
In the addres bar of your browser, type in "http://abc.com", for example.You should see the test index.html you've just created.If you don't see it, first, CLEAR the browser cache.And reload the page (By F5, CTrl-F5, or Reload button)If it doesn't work go to the trouble shooting section, bellow.
- Populate your contents
By using WebFTP or other software, put your contents in the directory you've created for sub/pointed domains.You can always ask assistance in PowWeb forum if you have problem.
The source code of the setup script
/tools/genht_php.txt<? # # genht.php # # Note: # If you already have sub/pointed domain with .htaccess, # probably you will need to edit .htaccess manually, # # If you are using DomainManager, I recommend just leep using it # unless you are willing to convert everything to this method # or to handle delicate arrangement of RewriteRules. # # 1. Put this file in a protected subdirectory under main /htdocs, # /www/U/USER/htdocs/protected/genht.php # using WebFTP, sitemanager, or other utility. # Note. You can use sitemanager, or other tools to protect a directory. # 2. Access http://yoursite.com/protected/genht.php # 3. Examin "Proposed .htaccess code" # 4. If it looks fine, click one of the link to setup. # 5. Remove this script. # 6. Creat directory that matches desired sub/pointed domain name. # /www/U/USER/htdocs/ <== main /htdocs # /www/U/USER/htdocs/sub.domain.com/ <== directory for sub.domain.com # /www/U/USER/htdocs/2nd-domain.com/ <== directory for 2nd-domain.com # /www/U/USER/htdocs/sub.2nd-domain.com/ <== directory for sub.2nd-domain.com # # Please read http://check-these.info/hosting/Generic_htaccessMethod.html # for more details. # $ver = "0.4"; $title ="Generic .htaccess method setup"; echo <<<END_HEADER <html><head> <title>$title</title> <body bgcolor=#eaeae7> <h1>$title</h1> <hr> <blockquote> END_HEADER; $user = get_current_user(); $domain = $_SERVER['HTTP_HOST']; preg_match('/^(www\.)?([^.]+)\.(.*)$/', $domain, $m); $maindomain = $m[2]; $tld = $m[3]; $htname = $_SERVER['DOCUMENT_ROOT'].'/.htaccess'; $vdrcode = <<<END_VDR # Virtual document root processing for CGI/PHP RewriteRule ^/*virtualdr.cgi - [L] RewriteRule ^/*[^./]+\.[^/]+/.*\.(cgi|php5?)\$ virtualdr.cgi [L] END_VDR; if(isset($_GET['doit']) && $_GET['vdr'] != 'yes' ){ $vdrcode = ''; } $hta = <<<END_HTA RewriteEngine on RewriteBase / $vdrcode # Loop stopping RewriteRule ^/*[^./]+\.[^/]+/.*\$ - [L] # Code for missing Trailing slashe problem RewriteCond s%{HTTPS} ^((s)on|s.*)$ RewriteRule ^/*(.+/)?([^.]*[^/])$ http%2://%{HTTP_HOST}/$1$2/ [L,R=301] ######## # Put most other RewriteRules that applies to all domains, here. # (Force www, Remove www, Bad browser kick out, Anti-leech, ...) ######## # Sub/pointer domain rewrite code RewriteCond %{HTTP_HOST} !^(www\.)?($maindomain\.?$tld|$user) [NC] RewriteCond %{HTTP_HOST} ^(www\.)?(.*)\$ [NC] RewriteRule ^(.*)$ %2/\$1 ######## # Put other RewriteRules that need prioror sub/pointed domain rewrite, here. ###### END_HTA; $chta = file_get_contents($htname); $bhta = preg_replace('/RewriteBase[^\n]*\n/mi', '', $chta); $bhta = preg_replace('/RewriteEngine[^\n]*\n/mi', str_replace('$','\\$',$hta), $bhta); if( ! isset($_GET['doit']) ){ echo <<<END_MESS <pre> This script will modify .htaccess so that you can manage sub/pointed/serviced domain by simply adding/deleting directory with corresponding name. Please read <a href="http://check-these.info/hosting/Generic_htaccessMethod.html">http://check-these.info/hosting/Generic_htaccessMethod.html</a> for more details. If you are currently using <a href="http://check-these.info/DomainManager.html">DomainManager</a> and "traditional .htaccess method", I'd recommend you to stay with it. When you click one of the link for setting up, it will make a backup of current .htaccess with the date and time suffixed. If you experience problem, you can simply delete .htaccess and rename the back up as ".htaccess". It'll copy virtualdr.cgi if you choose the link "with virtual document feature". Before to click the link for setup, take a look at "proposed .htaccess", bellow. <a href="?doit=yes&vdr=yes">Setup Generic .htaccess method with virtual document root</a> <a href="?doit=yes">Setup Generic .htaccess method without virtual document root</a> <hr size=8 color=blue><h1>Current .htaccess:</h1> $chta <hr size=8 color=blue><h1>Proposed .htaccess (with virtual document root):</h1> $bhta <hr size=8 color=blue> END_MESS; }else{ echo "<pre>Backing up '$htname' as '".$htname.'.'.date("Y-m-d_H-i-s")."'\n" ; copy($htname, $htname.'.'.date("Y-m-d_H-i-s")) ; echo "Updating '$htname'\n" ; $fh = fopen($htname,'w'); fwrite($fh, $bhta); fclose($fh); chmod($htname, 0640); $vdr = file_get_contents('http://check-these.info/hosting/genericx.txt'); if($vdrcode != ''){ echo "Setting up '$vname'\n" ; $vname = $_SERVER['DOCUMENT_ROOT'].'/virtualdr.cgi'; $fv = fopen($vname,'w'); fwrite($fv, $vdr); fclose($fv); chmod($vname, 0700); } echo <<<END_DONE <b>If you don't see any warning or error message, everything is done</b> Now, created directories that matche the sub/pointed domain name you like. /www/U/USER/htdocs/ <== main /htdocs /www/U/USER/htdocs/sub.domain.com/ <== directory for sub.domain.com /www/U/USER/htdocs/2nd-domain.com/ <== directory for 2nd-domain.com /www/U/USER/htdocs/sub.2nd-domain.com/ <== directory for sub.2nd-domain.com END_DONE; } ?>
Actual code used in this method
Code, with comment and instructions
Make sure to read this if you want to set it up, manuallygeneric.txt###### # # Note: You can use http://check-these.info/tools/genht_php.txt # to setup this code, automatically. # # 1. For sub.domain.com, create a directory sub.domain.com # under the main /htdocs, using WebFTP, sitemanager or other tools. # # /www/U/USER/htdocs/ <== main /htdocs # /www/U/USER/htdocs/sub.domain.com/ <== directory for sub.domain.com # # /www/U/USER/htdocs/2nd-domain.com/ <== directory for 2nd-domain.com # /www/U/USER/htdocs/sub.2nd-domain.com/ <== directory for sub.2nd-domain.com # # 2. To use virtual document root feature, put following script into # main /htdocs as "virtauldr.cgi" and set permission to 700. # http://check-these.info/tools/virtauldr_cgi.txt # # 3. Copy & Paste this code into the .htaccess of main /htdocs, # Using WebFTP or other tools. # /www/U/USER/htdocs/.htaccess # # And edit the line for skipping main domain, bellow. # You need to know the name of main domain, and main username. # These can be found in OPS -> Packages -> HTTP # # IMPORTANT: Please be aware that making mistake in the .htaccess # may cause general 500 internal server error. # Use WebFTP to edit again. # # Uploading .htaccess in wrong FTP transfer mode will cause # General 500 error, too. Use WebFTP to edit, # as It will save the file in correct line ending (LF). # # Please check following page for more detail/update: # http://check-these.info/hosting/Generic_htaccessMethod.html # RewriteEngine on RewriteBase / # Virtual document root loop stopper and rewrite code for CGI/PHP # Remove these 2 lines if you don't use this feature. # You must have /www/U/USER/htdocs/virtualdr.cgi with chomd 700 # for this feature to work. RewriteRule ^/*virtualdr.cgi - [L] RewriteRule ^/*[^./]+\.[^/]+/.*\.(cgi|php5?)$ virtualdr.cgi [L] # Loop stopper code RewriteRule ^/*[^./]+\.[^/]+/.*$ - [L] # Code for missing Trailing slashe problem # (to avoid double login or missing www) # RewriteCond s%{HTTPS} ^((s)on|s.*)$ RewriteRule ^/*(.+/)?([^.]*[^/])$ http%2://%{HTTP_HOST}/$1$2/ [L,R=301] ######## # Put most other RewriteRules that applies to all domains, here. # (Force www, Remove www, Bad browser kick out, Anti-leech, ...) ######## # Skip processing sub/pointed domain rules for; # MAINDOMAIN.COM, MAINDOMAINCOM.secure.powweb,com # USER.secure.powweb.com, or USER.temp.powweb.com. # # Edit 'MAINDOMAIN', 'COM', and 'USER' to fit your account. # DO NOT modify anything else, unless you know what you are doing. # You can find main domain name and USER name in OPS -> Packages -> HTTP # # example: RewriteCond %{HTTP_HOST} !^(www\.)?(yoursite\.?com|username) [NC] # # If you want your main domain to be redirected to # /www/U/USER/htdocs/MAINDOMAIN.COM, like other sub/pointed domains. # comment out by adding # or remove this line # RewriteCond %{HTTP_HOST} !^(www\.)?(MAINDOMAIN\.?COM|USER) [NC] # Sub/pointer domain rewrite code, main body RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$ [NC] RewriteRule ^(.*)$ %2/$1 ######## # Put other RewriteRules that need prioror sub/pointed domain rewrite, here. ########Code (without instructions)
genericx.txtRewriteEngine on RewriteBase / # Loop stopping and Virtual document root processing for CGI/PHP RewriteRule ^/*virtualdr.cgi - [L] RewriteRule ^/*[^./]+\.[^/]+/.*\.(cgi|php5?)$ virtualdr.cgi [L] RewriteRule ^/*[^./]+\.[^/]+/.*$ - [L] # Code for missing Trailing slashe problem RewriteCond s%{HTTPS} ^((s)on|s.*)$ RewriteRule ^/*(.+/)?([^.]*[^/])$ http%2://%{HTTP_HOST}/$1$2/ [L,R=301] # Sub/pointer domain rewrite code RewriteCond %{HTTP_HOST} !^(www\.)?(MAINDOMAIN\.?COM|USER) [NC] RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$ [NC] RewriteRule ^(.*)$ %2/$1Virtual doc root
If you want to use virtual doc root feature, you must placevirtualdr.cgi in the /htdocs of Main domain,and set permission of 700. (chmod 700)/www/U/USER/htdocs/virtualdr.cgiAs this script has a built-in safety system, you don't have to worryabout putting it in the publicly visible directory.This script does roughly same thing as Action directive, but changes DOCUMENT_ROOT, SCRIPT_URL, and a few other env variables in addition.Since virtualdr.cgi acts after all URL to path transformation andSuExec process, it can be used for setting ENV variables otherwise wiped out bySuExec .(TMP. TEMP, LD_LIBRARY_PATH, and so on)
Trouble shooting
IMPORTANT
Clear the browser cache and reload the page when you test.If you don't do that, you can waste your time, a lotVERY IMPORTANT
Remember to clear the browser cache and reload the page when you test.Forgetting this may cause frustration and embarrassment.Domain registration
- Make sure domain is registered, and it's not expired.
http://www.whois.sc/ and/or http://www.dnsstuff.com/DNS setup
- Make sure DNS is correctly setup.
It should resolve to the IP of your cluster.http://www.whois.sc/ and/or http://www.dnsstuff.com/Testing method
- Test main domain: http://maindomain.com/
- Test other domains: http://pointed-domain.com/
- Test sub domains if any:
http://sub.maindomain.com/http://sub.pointed-domain.com/- Test subdirectories of each domains (if applicable).
http://maindomain.com/subdir1http://pointed-domain.com/subdir2http://sub.maindomain.com/subdir3http://sub.pointed-domain.com/subdir4- Test scripts
http://maindomain.com/some.phphttp://maindomain.com/subdir1/some.cgihttp://pointed-domain.com/any.cgihttp://sub.maindomain.com/another.phphttp://sub.pointed-domain.com/subdir4/other.cgi- Test with pe.cgi or pe.php
Putt one of these in the directory you want to test,and access it to see the ENV variables.Env variables such as REDIRECT_STATUS, REDIRECT_URL may show you what's going on.pe.cgi (set permission to 700)#!/bin/sh echo printenv |sortpe.php<pre><? echo `printenv |sort`; ?>
- Test with bogus URL
While the access_log shows the requested URI before the transformation,error_log will show the absolute path of the file afterall redirect and transformation have happend.So, try a bogus URL, and check the error_log to see if the URL to path transformation is working as desired.
- If you edit .htaccess with an editor, or uploaded with a FTP
If you know how to edit plain text file and upload itand you can read and follow instruction,you shouldn't experience any problem.In other words. most problem are caused by fundamental lack of the knowledgeand/or simple mistakes.Follow these steps EXACTLY for creating/editing .htaccess fileor for ensuring the file format and line endings are correct.By saving the file with WebFTP, you can be sure that it hascorrect line ending and character code.1. Login to WebFTP.https://webftp.powweb.com/Put host name that came with welcome e-mail. ex. ftp05.powweb.comUse the correct username and password for FTP2. Click on