Skip to Content

Aarron Walter

XHTML | CSS |

My Book: Building Findable Websites

Building Findable Websites: Web Standards, SEO, and Beyond
Building Findable Websites: Web Standards, SEO, and Beyond
Aarron Walter
Buy on Amazon
Book's Companion Website
Companies waste fortunes seeking a magic bullet for Search Engine Optimization. But the keys to honest, effective web findability are appropriate writing and semantic markup. Aarron Walter’s wonderfully lucid and informative book tells everything you need to know to get your web content (or your client’s) in front of as many appreciative readers as possible.

- Jeffrey Zeldman, founder, Happy Cog Studios author, Designing With Web Standards, 2nd Edition

Now playing on my computer

MSNBC.com copyright 2008 FF-RE – MSNBC Hardball wit... Track | Artist
cnet.com – Buzz Out Loud 761: Debt by data plan Track | Artist
The Smiths – Death of a Disco Track | Artist
Flii Stylz – Rize Score Suite (with Flii Stylz & Re... Track | Artist
Wilco – Instrumental #2 (Take 2) Track | Artist
My Playlist Feed | My Last.fm Profile

Recent Photos From Flickr

Hatch Show Print Posters, Thu, 12 Jun 2008 14:49:05 -0800 Hatch Show Print, Thu, 12 Jun 2008 14:46:11 -0800
Hatch Show Print, Thu, 12 Jun 2008 14:43:52 -0800 Ari, Thu, 12 Jun 2008 14:21:10 -0800
My Flickr Photo Stream | All Photos

Running Two Domains On One Shared Hosting Server

15 Jan . 2007

Most people run their web sites on one of the many inexpensive shared hosting servers running a LAMP environment. If you are like me, you probably have a number of domain names registered, perhaps all parked on the same server pointing to the same site. It would be great to split things up, though, to point one domain to a particular site on your server, and other domains to their own site. Apache lets you do this using a special .htaccess file, which configures the server software on the fly. You can set up unique sites in their own directory on your server, and then
direct Apache to point requests for a particular domain to that folder. Let’s assume the domain you want to redirect is called “somedomain.com”, and the folder on your server where the site files reside is called “somedomain”. Create a plain text file with a text editor and add the following to it:

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

If you are on a Mac or Linux machine, you will need to save the file as something like htaccess.txt so the operating system does not hide the file (.htaccess is a special name the operating system recognizes, and will try to interpret the commands within). Upload the file to the root directory on your server (sometimes called, htdocs, public_html, or www among other names). Rename it .htaccess, then try accessing somedomain.com in a browser. It should direct your request to the files within the somedomain folder transparently, giving the effect of multiple domains with their own site running on the same shared hosting environment.

3 Responses to “Running Two Domains On One Shared Hosting Server”

  1. Chris Boudy Says:

    Hi Aarron, (Chris here again)

    Just wanted to ask a question about this method. Would this work with multiple domain name on the same server? For example, let’s say I added

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

    RewriteEngine On
    Options +FollowSymlinks
    RewriteBase /
    RewriteCond %{HTTP_HOST} anotherdomainihave.net
    RewriteCond %{REQUEST_URI} !sanotherdomainihave/
    RewriteRule ^(.*)$ anotherdomainihave/$1 [L]

    RewriteEngine On
    Options +FollowSymlinks
    RewriteBase /
    RewriteCond %{HTTP_HOST} a3rddomainihave.org
    RewriteCond %{REQUEST_URI} !a3rddomainihave/
    RewriteRule ^(.*)$ a3rddomainihave/$1 [L]

    to my .htaccess file. Would this work or is it only for two?

    Thanks

  2. Aarron Says:

    You have the general idea here, but you should be able to abbreviate it as follows:

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

    RewriteCond %{HTTP_HOST} anotherdomainihave.net
    RewriteCond %{REQUEST_URI} !sanotherdomainihave/
    RewriteRule ^(.*)$ anotherdomainihave/$1 [L]

    RewriteCond %{HTTP_HOST} a3rddomainihave.org
    RewriteCond %{REQUEST_URI} !a3rddomainihave/
    RewriteRule ^(.*)$ a3rddomainihave/$1 [L]

  3. Jaunty Says:

    I used your method before and it worked. But I’m trying it again after reseting my servers and it’s not working.

Share Your Thoughts

* indicates required