While you develop your Drupal site you may want to show the public either a simple holding page or keep an older version of the site operational.
You can either develop Drupal in a subdirectory while keeping the site in place, or you can develop Drupal in the webroot and put the holding page or old site in a subdirectory. This page considers the latter approach.
This technique can also be used to display a more friendly message than the standard 'Can't connect to the database' message when your site goes down.
For a module-based approach, see http://drupal.org/project/holding.
Instructions
Create your static holding page(s) and place it in a subdirectory called, for example, 'holding'.
Then add the following lines to your Drupal installation's .htaccess file, below the 'RewriteEngine on' line:
##### rewriting for holding page
RewriteCond %{HTTP_HOST} mysite\.com [NC]
RewriteCond %{REQUEST_URI} !^/holding [NC]
RewriteCond %{HTTP_HOST} !^drupal [NC]
RewriteRule ^(.*)$ /holding/$1 [L]
##### end
Replace 'mysite\.com' with the domain name of your own site, escaping the full stops with backslashes, as in the example.
This will redirect visitors of 'mysite.com' to 'mysite.com/holding', without them realising.
To access your Drupal site, you need an alternative domain name. There are two ways to do this.
- The easiest method is if you have the original domain name for your hosting, such as 'mysite.somehostingcompany.com'. Using this to reach your site will give you the Drupal site rather than the holding site. You may also be able to access your site at your IP like this: http://1.1.1.1/~username
- Alternatively, create a subdomain called 'drupal' for your site, set to the same webroot as the main domain. The third line in the code snippet above means that visiting 'drupal.mysite.com' won't be redirected to the holding page.
If you get a 403 for the holding site, you'll need to put an .htaccess file in the holding folder, as Drupal's .htaccess only allows index.php as a directory listing. This is all you need for the holding/.htaccess file:
# Set the default handler.
DirectoryIndex index.php index.html
Comments
I added this to my local
I added this to my local VirtualHost setup as it would give errors about
The main DirectoryIndex setup allows index.php which seems to mess it up so i added another Directory tag for the holding folder
Here is the setup:
my hosts file points to my localhost so i can test this redirect setup:
My best guess is that apache thinks the index.php actually does exist at the root web folder of mysite.com and gets confused?, as we trying to only go into the subfolder (without changing the url).
Almost right
I had to modify above code to work in my setup. I have Drupal 6.x installed in the root of my server directory and my old static site installed at holding/
I want to continue using the static site while I am finalizing the Drupal design. The .htaccess rules got close but I had to change the last Rewrite Rule
From
RewriteRule ^(.*)$ /holding/$1 [L]
To
RewriteRule ^(.*)$ /holding$1 [L]
I am not a .htaccess expert so take my experience for what it is worth.