Last updated December 21, 2012. Created by markusmf on April 10, 2007.
Edited by neerajskydiver, jhomme, joachim, LeeHunter. 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:
- In your webserver root's .htaccess file, find the section marked with the comment '# Various rewrite rules.'
- 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.phpto
http://www.example.com/drupal/index.phpDrupal 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.
I really want to do this!
mmoreno's solution didn't quite work for me (Linux), but this did:
http://drupal.org/node/144643
My review of David Mercer's "Drupal: Creating Blogs, Forums, Portals and Community Websites"
My review of David Mercer's "Drupal: Creating Blogs, Forums, Portals and Community Websites"
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.
subfolder .htaccess with exemptions uncommented failed for me
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
-Blake
www.BlakeSenftner.com www.MissingUbercartManual.com www.cg-general-store.com www.droplabs.net
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.
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
Any luck with this? I've been
Any luck with this?
I've been trying to take my website live for a while now but just can't work it out.
What's the process? How do you get all your modules, the database, and the theme files over to the live sever?
Thank you.
Root folder
"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)" - can someone clarify what the root folder is? Is that the folder where index.php, and subfolders, includes, misc, sites, modules, themes, etc. is? Thanks.
no
let's say, you are using XAMPP,
you can place your files in C:\xampp\htdocs\drupal and it is accessible thru http://localhost/drupal
you root directory is the htdocs folder...
Drupal 6 instal folder moving
Hello there.
I'm using drupal 6 on a cpanel based server and moving the installation folder from subdomain 'http://www.mydomain.com/web2' to another subdomain named 'http://www.mydomain.com/web' doesn't work. The site's homepage loads ok, but as soon as I try to load another page in it or logg in I get the message "Page not foud". It looks like the url's drupal created point to the old place.
I tried changing the file settings.php, uncommenting the statement and making it: $base_url = 'http://www.mydomain.com/web';
So moving drupal installation doesn't work on drupal 6? Do I have to use one of those strategies with .htaccess to be able to fool it into moving it arround?
Thx
DrupalMan
works only on the root
i followed the instructions provided above...
it works fine when I accessed http://example.com
but when i click on the another tab, let's say about us,
the URL changed to http://example.com/about
but the page appeared is the same as in the home page, http://example.com
yes, it really changed the URL, but it doesn't redirect to the right destination ..
any help would be appreciated.