Helping the World with KnowledgePosts RSS Comments RSS

Archive for the 'Web Development' Category

Pointing Add-on Domain to Existing Domain’s folder 2

In this article, I will guide you through a simple method to point an “add-on” domain (aka alternate domain) to an existing domain’s folder. There is another article about this, but compared to this, it requires more steps. This method, I believe does not work for Cpanel, unless you have somehow tweaked it’s file system. The method described in this article works for the Grid Service hosting account for MediaTemple, but it should work for other similar hosting environments too.

This is what I am attempting to do:
newdomain.com to show olddomain.com/folder and
newdomain.com/whatever-that-follows to show olddomain.com/folder/whatever-that-follows

You are required to have SSH access for this, which is available for (gs) accounts by default.

For the purpose of this article, newdomain.com and olddomain.com are used to explain the steps easily. You are trying to make newdomain.com appear as olddomain.com/folder. Please replace these names with your own.

Step (1)

Add the alternate domain to your account associated with your domain. (Note that domain name takes up to 48 to start working after you changed it’s nameserver.)

Step (2)

Create a directory(folder) under olddomain.com by any means you know. eg. “folder”

Step (3)

Connect to your SSH create a symbolic link from the newdomain.com to the olddomain’s folder you are trying to target by doing the following:

Ussing SSH, browse to your newdomain.com’s folder. In (gs), use the following:

cd domains/newfolder.com

Note:
cd is a command that moves you to another directory.
cd <relative to current dir> to move to that directory.
dir is a command that display all directories and files inside the current directory.
These are standard command line interface commands. Google for more.

Continue…

Now that you are in the newdomain.com folder. Use the following command. The following command assumes that you are using (gs), please modify it accordingly if your file system is structured differently. For (gs) users, replace ###### with own number too.

ln -s /home/######/domains/olddomain.com/html/[path to folder] ./html

Explaination:

ln -s is a command that creates a symbolic link from 1 path to another.
In this case, since we are in the newdomain.com folder, the ./html folder at the end is the sub-directory of the current folder you are in. Which is newdomain.com/html.

./html is linked to /home/######/domains/olddomain.com/html/[path to folder] (An absolute path to the olddomain.com’s folder you want).

More Information

If you are using Cpanel, please refer to the previous article.

For other Mediatemple accounts please refer to their kb article and adapt accordingly to achieve your desired result.

5 responses so far

Pointing Add-on Domain to Existing Domain’s folder

In this article, I am attempting to point an “add-on” domain (aka alternate domain) to an existing domain’s folder. This is, I believe, somewhat like what blogger.com does with its premium features, where users can use their own domain to overwrite the blogspot.com subdomain.

—-

Update: 2:30 PM 5/9/2008

A simpler method for doing this with (gs) account is discovered.

Please refer to Pointing Add-on Domain to Existing Domain’s folder 2

–End of Update–

This is what I am attempting to do:
newdomain.com to show olddomain.com/folder and
newdomain.com/whatever-that-follows to show olddomain.com/folder/whatever-that-follows

I am using mediatemple.com Grid Service (gs) as my host in this experiment, however those using Cpanel or other platforms should be able to do this as well, as long as you can add add-on domains.

Using mediatemple (gs) add-on domains must be configured manually using SSH after adding it as an alternate domain in their interface.

The following is for Mediatemple (gs) only, other platforms are most probably done differently as the folder structures are different. You can skip Step (1) if you are using Cpanel, you just have to add newdomain.com as a add-on domain to olddomain.com.

Step (1) Delete the existing domain’s folder. Although this can be done manually using FTP or the file manager, the SSH command is:

cd domainsrm -rdf newdomain.com

Then, create the sym link:

ln -s olddomain.com newdomain.com

Step (2) Now add a .htaccess file to olddomain.com’s web root directory (html folder of (gs) and public_html folder for Cpanel)

The contents of the .htaccess file (”thefolder” is the folder within olddomain.com’s root folder that I want newdomain.com to show):

Options +FollowSymlinks

RewriteEngine On

RewriteBase /#Fix trailing slash issue

RewriteCond %{REQUEST_URI} ^/[^.]+[^/]$

RewriteRule ^(.+)$ http://%{HTTP_HOST}/$1/ [R=301,L]

#Send to the correct web site directory

RewriteCond %{HTTP_HOST} newdomain.com

RewriteCond %{REQUEST_URI} !thefolder/

RewriteRule ^(.*)$ thefolder/$1 [L]

Completed (!) Now newdomain.com should be showing olddomain.com/thefolder.

Replace with your own domains/folder names for it to work.

This is a totally manual method, but you could create a php script to modify the .htaccess to partially automate it so that users can fill in the form with their domain at olddomain.com.

In theory, you could create a bot on your computer or run a program on server side to fully automate this which might be what blogger.com is doing. However, I don’t think (gs) supports such server side programs.

I not an expert at .htaccess, maybe there is a way to do this where I don’t need to modify it everytime.

3 responses so far