Tag Archives: Drupal

Drupal, Clean URLs, IIS, and ISAPI Rewrite

Yesterday I had to deploy a Drupal site to a client's server. Our development server runs Ubuntu 8.04, Apache, PHP,  and MySQL. Our client's server runs Windows Server 2003, IIS, PHP,  and MySQL.  The goal was to perform a clean move that implemented clean URLs. Following are the steps that I followed. They are split into two parts: Deploy and Clean URLs.  I do assume that you already have PHP and MySQL installed and working properly with IIS.

Deploy

  1. Turn off clean URLs in Drupal (Administer -> Site Configuration -> Clean URLs)
  2. Export current site database using PhPMyAdmin.  You will most likely run into an error saying that the import file is too large for PhpMyAdmin or that there is trouble inserting the data from the cache_ tables. If this is the case, the following two steps should solve your problems:
    • Export all tables (including data) except for those starting with cache_
    • Export the structure of all tables starting with cache_
  3. Create the database on your new server using PhpMyAdmin
  4. Import the data exported in (2)
  5. Copy all of your Drupal file into your new location. Also create the virtual directory or website for this directory in IIS.
  6. Adjust the database settings for Drupal in your sites/default/settings.php file
  7. Everything should be working!

Clean URLs

  1. Download and install Helicon ISAPI Rewrite 3 Lite
  2. Open the httpd.conf file in the installation directory
  3. Save httpd.conf as httpd.ini
  4. Enter the following in httpd.ini
    1
    2
    3
    4
    5
    6
    
    [ISAPI_Rewrite]
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?1=$1 [L,QSA]
  5. If you have Drupal installed in a sub-directory (/drupal/) change RewriteBase to /drupal/. Do remember that ISAPI Rewrite 3 Lite only supports 1 domain or site! This makes the RewriteBase very important!
  6. Enable Clean URLs in Drupal (Administer -> Site Configuration -> Clean URLs)
  7. Enjoy your clean URLs1