Community Documentation

Taking your site live

Last updated March 16, 2011. Created by markusmf on April 10, 2007.
Edited by jhomme, joachim, LeeHunter, xamount. Log in to edit this page.

Once you've got your Drupal installation set up just the way you want it, there are a few final considerations before you unleash it on the world.

Moving from a temporary location

It's likely that you've put Drupal in a subfolder on your server, so it doesn't interfere with your existing website while you get it set up. So you have www.example.com showing your old site, www.example.com/drupal showing drupal, and you want www.example.com to show off your new site to the world. There are two ways you can go about this:

Moving Drupal

For newer versions of Drupal, moving the Drupal base folder shouldn't pose any problems. For versions prior to Drupal 5, some settings may need to be changed so Drupal can find everything. See this forum thread for more details.

Redirecting your server

Alternatively, you can leave Drupal where it is in a subfolder, and just have your webserver fool everyone into thinking that folder is www.example.com.

With Apache, you need to add the following to the .htaccess in the root folder (or create an .htaccess file if there isn't one there):

RewriteEngine on
#
# stuff to let through (ignore)
#RewriteCond %{REQUEST_URI} "/folder1/" [OR]
#RewriteCond %{REQUEST_URI} "/folder2/"
RewriteRule (.*) drupal/$1 [L]

Use the RewriteCond rules to let through URLS without modification (for example, you might have other subfolders you still want accessible). Replace 'drupal' with the name of the folder Drupal is in.

You also need to modify the settings.php file for your site. By default, this is at sites/default/settings.php. Uncomment (or change) the line that sets $base_url, and set it to the URL you want browsers to see as the base for your site:

$base_url = 'http://www.example.com';

In other words, ensure that this does not include the drupal subdirectory. This changes the links that Drupal generates so they point to the correct location.

Excluding paths from Drupal

It may be that your site is made up components other than Drupal, or that you have an archive version of your old site you want to be browsable. Drupal in a root folder takes over all URLs; Drupal in a subfolder fooled into thinking it's root likewise.

Either way, the .htaccess file in the root folder needs to be changed to let through the paths to files or folders you want Drupal to ignore.

In the case where Drupal is in the root folder, here's what you need to do:

  1. In your webserver root's .htaccess file, find the section marked with the comment '# Various rewrite rules.'
  2. Below 'RewriteEngine on' but before any other rules, add lines in the following form:
      RewriteRule /folder - [L]     # a subfolder Drupal should ignore
      RewriteRule /file.html - [L] # a file in root Drupal should ignore

This page is a work in progress. Please suggest other tasks it should cover.

Comments

Hiding the subdirectory...

The trick to hiding the drupal subdirectory is not letting drupal know about it - only the rewrite rule.

Put this rewrite rule in .htaccess:

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

However, ensure that the $base_url variable in settings.php does not include the drupal subdirectory:

$base_url = 'http://www.example.com';

This will convert a request for:
http://www.example.com/index.php
to
http://www.example.com/drupal/index.php

Drupal will then generate URLs without the subdirectory and depend on the rewrite rule to fix it.

(Note that I've only tried this with drupal 5.1 on IIS)

BTW, note that your rewrite rule is slightly incorrect in that a request for /index.php would be translated into drupal//index.php, which might be harmless but incorrect nevertheless.

More on hiding the subdirectory

The tip from mmoreno does work on Apache as well, with some minor modification (tested on Ubuntu 7 + Apache 2.2.4).

Within my virtual host configuration (I have Drupal running with HTTPS access only), I added the following:

RewriteRule ^$ /drupal/ [L]
RewriteRule /phpmyadmin - [L]
RewriteRule ^(.*) /drupal/$1 [L]

Originally, I only had the last two lines above, however, this caused a "Bad Request" error in Apache because of a bad URI. After some digging, I decided to add a special rule to handle requests to "http://www.example.com" as well. This corrected the Bad Request issue and now my Drupal installation is running perfectly.

i had to do something more like:

RewriteEngine on
#
# stuff to let through (ignore)
RewriteCond %{REQUEST_URI} "!/folder1/"
RewriteCond %{REQUEST_URI} "!/folder2/"
RewriteRule (.*) drupal/$1 [L]

(invert conditions and use implicit AND)

brian

A solution for godaddy hosted sites

I've documented how to get drupal in a subdirectory with godaddy hosting here:
http://drupal.org/node/520700

What about DB files path?

There is a database table for information about files attached to nodes named 'files'. It has a field 'filepath', which includes site name like 'sites/site_name/files/file_name'. I'm deploying drupal version of one of my sites near its current working version which is outside of drupal. Both are available as apache virtual hosts, so I'm unable to use site original name while deploying. Any ideas?

Seems done.

I used another port for new version of a site virtual host and renamed its directory inside drupal tree to real site name and that seems working - now I can work with something like real_site_name.domain:PortNum/node/nn and database stores correct pathes.

You can use symbolic links in

You can use symbolic links in the sites folder. The thing to do from start is to have your eventual live site folder name as the real folder, and the symlink be the site name your local site needs.

Redirecting

I've been running my site in a subfoder for a while and didn't have it set up correctly. I'd like to see instructions on redirecting any incoming links to the rewritten paths.

"Redirecting your server" for Drupal 7?

Does the trick explained under "Redirecting your server" works for someone with Drupal 7?
It doesn't work for me.

Drupal 7

Does anybody have the key to making this work in Drupal 7? I've done much research and got the front page to load but clicking on the links will put the url in the address bar, but the front page remains. Also it's looking for jquery under the main directory and not the subdirectory. Any help would be appreciated.

Deploy to diiferent server

sorry just starting with drupal
Would be good to add some words about steps for deploying to a " go live" server from a development machine
Thx

Wseguin