Drupal Tutorials
Drupal Sub domain configuration
You should be comfortable with server configurations and will to get your hands dirty (a bit).
Big thanks to Ariene Ellefsen for writing this great little tutorial for DrupalSN, thanks Ariene!
Hello Everybody,
I’d like to share this tutorial with you about how to set up subdomains on your website using Drupal and a few server tricks.
So why use subdomains?
Subdomains offer 3 main advantages:
- Google treats a sub domain as a totally different website from its main domain
- You can use any keyword(s) as a subdomain
- It doesn’t cost you any extra money to set up a subdomain (with most host companies).
So, if your agent website is hosted on a domain name like, “ellewebdesign.com“, you can set up an unlimited number of subdomains (providing you host company permits it, check with them), such as…
portfolio.ellewebdesign.com
blog.ellewebdesign.com
project.ellewebdesign.com
And so on. The good news is that the keywords in the subdomain name carry SEO importance, just like the keywords in the domain name. Combine that with the fact that Google sees each subdomain as a separate website, you’ve got a great way to create lots of backlinks.
Here’s another Google advantage. As it is now, each search results page on Google will show a maximum of two listings from the same website. But if you set up subdomains, it’s possible to dominate all 10 listings on the first results page of Google!
So subdomains can offer big SEO (Search Engine Optimization) advantages as well as looking professional.
We have all heard by now the advantages of having a blog for promoting your website. So why not try it and create a blog using this technique and subdomains for your site!
Once you have your blog, adding a link to it on your menu takes a couple of seconds, and voila – your blog is up and running. This is the part where you feverishly start posting articles about your niche market, your product, or your service, and link to your website from each article.
Blogs are amazing: Search Engines love them, and they generally get good PR very quickly.
Good luck and I hope this tutorial will show you the importance of using subdomains.
Subdomain Setup
Let’s get stuck in and set up our subdomains.
For these examples we are using XAMPP for Windows.
Step 1: Server Setup
1 First let’s create a DNS entries file for the website (The purpose of creating the DNS entry is to be able to test the sub domains in our local machine)
DSN (Domain Name System) tells your server where a subdomain or web address should be directed to. It’s basically a way of putting a human readable name over the top of an IP address.
2 To find the host file (that we can add our DSN entries to) go to: C:\WINDOWS\system32\drivers\etc\ then open the “hosts” file using Notepad.
Add the following entries, then save and close the “hosts” file:

3 Next we need to alter our Apache VirtualHost settings to look for the new subdomains.
Locate your servers httpd.conf or httpd-vhosts.conf file (which one you have depends on your server setup), if you are using XAMPP you’ll find it at:
On Linux you will find your httpd.conf file at:
So go ahead and add the following to the bottom of your httpd.conf or httpd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "C:/Program Files/xampp/htdocs"
ServerName localhost:80
</VirtualHost>
<VirtualHost www.site.local:80>
DocumentRoot "C:/Program Files/xampp/htdocs"
ServerName www.site.local:80
</VirtualHost>
<VirtualHost www.blog.site.local:80>
DocumentRoot "C:/Program Files/xampp/htdocs"
ServerName www.blog.site.local:80
</VirtualHost>
You’ll need to restart Apache to this change to take affect.
On Linux use: apachectl -k restart
On XAMPP you can use the XAMPP control panel or restart your computer.
Great!! We already have two subdomains but to make it works we need to create a folder inside of our apache installation.
Step 2: Drupal “sites” folder setup
1 Go to: C:\Program Files\xampp\htdocs and create a folder called “www.site.local”, this is where your default Drupal installation will reside so add all your Drupal installation files to this folder.

Proceed with the Drupal installation and test the site on your local machine.

Step 3: Let’s create our subdomain
We going to create a “blog” subdomain (blog.site.local) for our main Drupal install (www.site.local).
1 Let’s add the new subdomain folder inside of C:/Program Files/xampp/htdocs/www.site.local/sites and call it “blog.site.local” (see screengrab below).

The new “blog.site.local” folder will contain all the settings, themes and modules that are specific to the new subdomain, any modules or themes common to all sites should go in you sites/all folder.
Find out more about installing modules and themes.
2 Now we need to create a new settings.php file for Drupal to recognize that the blog.site.local is a subdomain of the main www.site.local domain.
A) Copy the settings.php file from www.site.local/sites/default to the folder blog.site.local

B) Now we need to decide if we want our subdomains to share the same database or to have a different database for each subdomains (a Drupal multisite setup).
I will explain how to set up both. Let’s start with a single database for each subdomain:
1 Open the settings.php in our new “blog.site.local” folder and modify the $db_url and $db_prefix to reflect our database settings.
Let’s replaced the line below with our database, username and password:
<?php
//$db_url = 'mysql://username:password@localhost/databasename';
$db_url = 'mysql://drupal:drupal@localhost/drupal_db';
?>2 Now we need to alter the $db_prefix variable so that all our database tables for this subdomain are preffixed with some text so we can distinguish between them and the main domain tables.
You can choose any prefix you want for your $db_prefix configuration, I’ll use ‘blog1_’:
<?php
$db_prefix = 'blog1_';
?>And that is it!! Here you have a drupal site with subdomains using a single database!!!
Now just point your site to: www.blog.site.local and proceed with your installation. Each subdomain will have our own database.
Follow the exactly the same proceedure as with the sinle database set up but make sure you leave the $db_prefix blank:
<?php
$db_prefix = '';
?>And that is it!! Here you have a drupal site with subdomains using a multiple database!!!
Now just point your site to: www.blog.site.local and proceed with your installation. Your subdomain will share the same database.
I hope this tutorial is helpful!!! Thank you for reading!!
Ariene Ellefsen
http://www.ellewebdesign.com
Some really great SEO tips
By Imafilmmaker on Monday, May 11, 2009Some really great SEO tips about subdomains! Many people overlook the importance of using keywords in the URL. Thanks so much for this tutorial. Do you know how to do this using MAMP on OSX? I’m not sure I understand how to access the DNS on a mac.
I use this to manage my
By erclerico on Wednesday, May 20, 2009I use this to manage my local hosts on my Mac – very handy for off-line development: http://www.northernsoftworks.com/hostal.html
Your exactly right Ima, it's
By merchantvice on Tuesday, May 4, 2010Your exactly right Ima, it’s also important that you to make the url keyword rich also like example putting the keyword lets say pool cleaners you can insert this keyword like this www.domain.com/poolcleaners or www.domain.com/pool-cleaners but for me this is more effective; www.domain.com/pool_cleaners
:)
Really a fantastic tutorial
By nazar2k2 on Friday, September 18, 2009Really a fantastic tutorial for creating the sub domains.thanks for this great tutorial.Also can you please tell me how to do this using Lamp on OS?
Thanks
Thank you for this great
By Program on Friday, November 20, 2009Thank you for this great info, I was struggling to write a subdomains for very long, eventually i got idea here.
fat burning furnace
Superb tutorial and you are
By richardb on Monday, May 10, 2010Superb tutorial and you are right it is important to get the keyword in the url. Thanks again andrew reynolds from debt solutions you guys are my favourite drupal resource!
This is a great tutorial. I
By JulesDM on Sunday, December 6, 2009This is a great tutorial. I was having some issues with this when setting up a subdomain. It turns out the issue was with my GoDaddy account. I finally got my subdomain resolved, but this tutorial is still helpful nonetheless.
automatically creates
By cChristina on Friday, April 16, 2010automatically creates subdomains for your site and assigns nodes to those subdomains.Website Placement
Thank you editors for the
By kiran1234 on Monday, April 19, 2010Thank you editors for the topic.Its include a lot of useful informations. i join this blog i couldnt see unnecessary arguments and it makes us happy thnx all moderator n editors. Wedding cards
This tutorial has give me
By Furnace on Thursday, December 10, 2009This tutorial has give me clear instruction on set up subdomains on my website using Drupal and a few server tricks. — fat burning furnace and fatburningfurnace review
The new "blog.site.local"
By Select on Wednesday, December 30, 2009The new “blog.site.local” folder will contain all the settings, themes and modules that are specific to the new subdomain, any modules or themes common to all sites should go in you sites/all folder.
jump higher and Mp3 rocket pro
I really like your website
By postreplytwo on Saturday, April 17, 2010I really like your website and daily watch it for latest articles because you provides many knowledge about many things.
tramadol online
buy tramadol
tramadol
Thank you for another great
By Nathanial on Sunday, January 3, 2010Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information.
Great!! We already have two
By deff_lepp on Wednesday, February 3, 2010Great!! We already have two subdomains but to make it works we need to create a folder inside of our apache installation.
Wrinkle Cream Reviews||Lifecell Cream
I havent tried drupal before
By Boffman on Thursday, February 18, 2010I havent tried drupal before but now i feel like trying drupal… lets see how it would feel.. thanks for the tut of Pure Acai Berry
I was having some issues
By rishi on Thursday, April 22, 2010I was having some issues with this when setting up a subdomain. Now it is resolved. Thanks!
watch tv online
WiredTree.com Coupons. I
By jackb on Monday, February 22, 2010WiredTree.com Coupons. I needed a new server, and I already had a Wiredtree VPS which I was 100% satisfied with. I decided I’d try out a huge package from Wiredtree! I needed something big for the website I was running that was getting thousands of hits a day. I used this WiredTree.com Coupons and it saved me over $300 dollars a month on the total offer. Wicked!
That's a very useful plugin,
By royalt on Sunday, March 14, 2010That’s a very useful plugin, I’m gonna use it on my Drupal site.
online games
dress up games for girls
The amount of insurance
By wify on Saturday, March 20, 2010The amount of insurance contribution is determined by several criteria like the region,the type of car or the personal way of driving.
Regards,
auto insurance quotes
Great tutorial. Drupal rocks
By Annat on Tuesday, March 23, 2010Great tutorial. Drupal rocks and with tips like these … Rock on!
i agree, its a great
By Henna on Monday, May 10, 2010i agree, its a great tutorial and everything has been explained so nicely, i think drupal is one of the most effective new technologies that are working these days!! good job }:)
Great tips indeed. I am
By getbrowser on Tuesday, March 30, 2010Great tips indeed. I am ready to build a site with Drupal and this guide is really useful to me. Thanks very much.
Place a new
By rishi on Tuesday, March 30, 2010Place a new yoursubdomain.youdomain.com directory in the sites/ directory. This contains a settings.php file configured for this site, and optionally custom themes and modules for the subdmain site.
Buy domain name
Drupal is competating now
By Resveratrol on Thursday, April 8, 2010Drupal is competating now with Wordpress.. I like Drupal though.. Just like Resveratrol Supplements
Subdomain automatically
By rishi on Saturday, April 10, 2010Subdomain automatically creates subdomains for your site and assigns nodes to those subdomains.
shopping cart software
i never seen tutorial like
By inkcartridges on Sunday, April 11, 2010i never seen tutorial like there before, very gr8 tutorial, thx 4 share it.
Canon printer ink
the Drupal sub domain
By buzzzinezz on Friday, April 16, 2010the Drupal sub domain configuration tutorial with images looked amazing. almost removed all of my doubts… Just like Free Energy Generator
Free Energy Generator Plans
Great help works good for
By syam on Saturday, April 17, 2010Great help works good for me, but still there is some bugs…
Please help me..
Best of luck and
By rock333 on Monday, April 19, 2010Best of luck and congratulations.I have checked your site and I invite others please check it because the information that is available in your site can spell bound any one.and the images that you have shown in this site also very attractive. There is one more site that I have visited, provide me information that is really unique and the service that they offer also I have experienced 1z0-032 dumps, really I enjoy this service mcse courses so I request others please visit this and I want to tell you that after enjoying this service you’ll enjoy it again and again its .
We can assign our subdomains
By rishi on Tuesday, April 20, 2010We can assign our subdomains to share the same database or to have a different database for each subdomains a drupal multisite setup.
development
thanks for helping me out
By buzzzinezz on Tuesday, April 20, 2010thanks for helping me out with this stuff… LED Emergency Lights
You can read more on it
By sidkof on Wednesday, April 21, 2010You can read more on it here. http://drupal.org/node/43816
I did this the same way you do any multisite configuration. That is
A) Make sure http://yoursubdomain.yourdomain.com resolves to your nameserver’s public html directory
B) place a new yoursubdomain.youdomain.com directory in the sites/ directory. This contains a settings.php file configured for this site, and optionally custom themes and modules for the subdmain site.
Also, check out the install instructions that come with drupal. It outlines there how drupal looks at a URL and decides which sites/directory to use.
Sam Tresler,
Car Rental Locations
Established domains with a
By preetijuyal on Monday, May 3, 2010Established domains with a credible web presence and the age factor undoubtedly improve the SEO ranking capability with the search engines and allow the visitors to find the most trustworthy site easily.
.I have checked your site
By cChristina on Tuesday, May 4, 2010.I have checked your site and I invite others please check it because the information that is available in your site can spell bound any one.and the images that you have shown in this site also very attractive.Atlantis Hotel
I have been lookign for
By logodeisgns1 on Monday, May 10, 2010I have been lookign for Drupal Sub domain configuration, I was finding in google for last 2 weeks and i got this site very informative. Logo Design
I really like your website
By technex on Thursday, May 27, 2010I really like your website and daily watch it for latest articles because you provides many knowledge about many things. Rapis and dwcacarvers





Delicious
Digg
StumbleUpon
Facebook
Google
Yahoo
Technorati



















