Hey there guys. I had a quick scenario/question for you all.

Currently I'm using a shared host with multiple domains. My primary domain is just a few static pages without the need for a CMS. What I would like to do is install one instance of drupal for an add-on domain.

This add-on domain will sit inside a sub directory of the root of my primary domain. What I would like to do is install an instance of drupal inside this subdirectory which will host multiple sites. I've installed and ran multiple drupal sites within a single install by using drupals /sites folder functionality. My question is, how do I do this if drupal isn't installed at the root of my web server?

any help, ideas, etc. is greatly appreciated. Thanks!

Comments

lanny heidbreder’s picture

It sounds to me like you don't have a problem. If your subdomain.example.com points to a subdirectory of example.com, there will be no problem using subdomain.example.com. Just don't try to use example.com/subdomain.

Likewise if it's not a subdomain. If it's example2.com you're pointing to the subdirectory, you'll only have problems if you try to use example.com/example2.

If that doesn't accurately describe your situation, however, you may have problems and should rephrase your situation or wait for someone who understands it better than I do. :)

STyL3’s picture

I'm not pointing to a subdomain. I am indeed pointing to separate domains.

Say my primary domain is example.com. At any given time I may want this to run from a Wordpress install, a static page or even a drupal install. For the time being it is just a static page, so i'm not really concerned.

For my "add-on" domain, www.example2.com, I want it to use drupal. For this I can easily install drupal into a subdirectory called "drupal". At this point I would simply point my add-on domain to this directory and www.example2.com would be my primary drupal site.

Now comes the tricky part...or so I think. If I wanted to run www.example3.com from the same drupal install, how would I go about this? Since the primary drupal site (example2.com), isn't my primary domain (example.com), I can't simply park this domain and have drupal "work it's magic", by picking it up from the "sites" folder.

Would I have to make www.example3.com an add-on domain and point it to the "drupal/sites/example3.com" folder? This is were I'm confused.

STyL3’s picture

Nevermind, I figured it out. I didn't really have an issue at all. I simply installed drupal to a drupal subdirectory and point my domains to this directory. Drupal then takes over from there.

Thanks for the help though guys.

Matti303’s picture

With my shared hostgator account I could not point a domain to the drupal subfolder. Instead I had to add this to the .htaccess file in the public_html folder: (if your drupal root is public_html/drupal)

# Let drupal appear as installed in root for primary domain and all parked domains
RewriteEngine on
RewriteRule ^$ /drupal/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /drupal/$1 [L]

So when I add a parked domain, it will also go to the drupal folder.

Also modify the .htaccess file in the drupal folder:

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
RewriteBase /drupal

  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
#put /drupal/ in front of index.php to make clean url’s work with multiple sites
  RewriteRule ^(.*)$ /drupal/index.php?q=$1 [L,QSA]

http://reanimatepc.com

Matti303’s picture

I have been able to simplify the method I posted on the 19th of October 2008:

With my shared hostgator account I could not point a domain to the drupal subfolder. Instead I had to add this to the .htaccess file in the public_html folder: (if your drupal root is public_html/drupal)

# Let drupal appear as installed in root for primary domain and all parked domains
RewriteEngine on
RewriteRule ^$ /drupal/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /drupal/$1 [L]

So when I add a parked domain, it will also go to the drupal folder.

Also modify the .htaccess file in the drupal folder:

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
RewriteBase /   ->just uncomment this line

Now in the settings.php file of the website make sure this line is correct:

$base_url = 'http://yourdomain.com';  // NO trailing slash!

http://reanimatepc.com

tyates’s picture

Matti303 -

I racked my brain all morning before finding your post. Support at HostGator told me I was out of luck but your solution did the trick! Thanks.

Ted

hayskelly’s picture

This is how you get it to work. Worked great for me, I'm using a addon domain at hostgator, and I just did exactly this and it works. Thanks Matti

Rob T’s picture

Same issue w/ me and Hostgator, needing to redirect my primary domain to a subfolder.

Thanks for the great step-by-step.

ikeigenwijs’s picture

keeping track

Kruge’s picture

As far as I understood your question it will work just fine - I jsut started working with Drupal myself and I put my sandbox to www.brielmusik.de/briel2-0/

"Give a man a place by the fire and he'll be warm for a day. But set him on fire and he'll be warm for the rest of his life!" - Lord Havellock Vetinari, Patrician of Ankh-Morpork

Visit my music webpage: www.brielmusik.de