Apr 4, 2010

Install Drupal in a Sub-directory

The easiest way to install Drupal is to copy all the drupal files to your web server's document root or your public HTML directory (normally this is public_html directory).  However, this causes many issues.
  • There are other top-level directories under web root. The drupal files will clutter with them  in the root.
  • Themes, modules and configuration files are all under separate directories in the root directory.
  • Upgrades are problematic because of intermixing.
Therefore, I would prefer have Drupal installed in a subdirectory, and it will make maintenance a lot easier.

For reference, my living website (www.gleanergames.com) set up like this:

Follow these steps to install drupal in a subdirectory.
  • Extract all drupal files into a subdirectory named drupal. The directory structure should be:
    • public_html (root directory)
    • public_html/.htaccess
    • public_html/drupal
    • public_html/drupal/.htaccess
    • public_html/drupal/includes
    • public_html/drupal/modules
    • public_html/drupal/...
    • public_html/drupal/sites/
    • public_html/drupal/sites/default
    • public_html/drupal/sites/default/settings.php
  • Edit the .htaccess file in root directory (public_html/.htaccess), add these lines:

    RewriteCond %{HTTP_HOST} ^(www\.)?gleanergames\.com$
    RewriteCond %{REQUEST_URI} !^/drupal/
    RewriteRule ^(.*)$ drupal/$1 [L]

    Don't forget to change the domain name (gleanergames) to yours.
  • Save the .htaccess.
  • Open browser and type your domain name, you should be able to see your web site.
Please note, these steps allows you to install drupal in a subdirectory but access it as if it lived in the root. You don't need to change the .htaccess file in public_html/drupal/.

No comments:

Post a Comment