I've got a Drupal site, site.com, and our client includes a campaign that they are marketing that they have purchased a new domain title, campaign.com. I would like it to ensure that a request campaign.com internally rewrites to particular page from the Drupal site. Note Drupal uses an .htaccess file within the document root.

The standard Drupal rewrite is

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

I added the next before the standard rewrite.

# Custom URLS (eg. microsites) go here
RewriteCond %{HTTP_HOST} =campaign.com
RewriteCond %{REQUEST_URI} =/
RewriteRule ^ index.php?q=node/22 [L]

Regrettably it does not work, it simply shows the home page. Activating the rewrite log I recieve this.

1. [rid#2da8ea8/initial] (3) [perdir D:/wamp/www/] strip per-dir prefix: D:/wamp/www/ -> 
2. [rid#2da8ea8/initial] (3) [perdir D:/wamp/www/] applying pattern '^' to uri ''
3. [rid#2da8ea8/initial] (2) [perdir D:/wamp/www/] rewrite '' -> 'index.php?q=node/22'
4. [rid#2da8ea8/initial] (3) split uri=index.php?q=node/22 -> uri=index.php, args=q=node/22
5. [rid#2da8ea8/initial] (3) [perdir D:/wamp/www/] add per-dir prefix: index.php -> D:/wamp/www/index.php
6. [rid#2da8ea8/initial] (2) [perdir D:/wamp/www/] strip document_root prefix: D:/wamp/www/index.php -> /index.php
7. [rid#2da8ea8/initial] (1) [perdir D:/wamp/www/] internal redirect with /index.php [INTERNAL REDIRECT]
8. [rid#2da7770/initial/redir#1] (3) [perdir D:/wamp/www/] strip per-dir prefix: D:/wamp/www/index.php -> index.php
9. [rid#2da7770/initial/redir#1] (3) [perdir D:/wamp/www/] applying pattern '^' to uri 'index.php'
10.[rid#2da7770/initial/redir#1] (3) [perdir D:/wamp/www/] strip per-dir prefix: D:/wamp/www/index.php -> index.php
11.[rid#2da7770/initial/redir#1] (3) [perdir D:/wamp/www/] applying pattern '^(.*)$' to uri 'index.php'
12.[rid#2da7770/initial/redir#1] (1) [perdir D:/wamp/www/] pass through D:/wamp/www/index.php

I am not accustomed to mod_rewrite, and so i may be missing something, but evaluating the logs from the call to http://site.com/node/3 and from http://campaign.com/ I can not use whatever significant difference. Particularly uri and args online 4 appear correct, the internal redirect online 7 appears right, and also the pass through online 12 appears right (since the file index.php is available). But for whatever reason it appears the query string's been thrown away/overlooked at about the time from the internal redirect. I am completely stumped.

Also, if anybody could give a reference on comprehending the rewrite log, that can help. It would be great if there's a method to track the query string with the internal redirect.

FWIW I am using WampServer 2.1 with Apache 2.2.17.

Thank you for asking this, it is something that I have to do too. I'm not sure the best way to do that by way of the .htaccess, and hope that somebody here can answer that.

However I perform the same factor by utilizing Drupal's menu system with this particular code inside a custom module:

function mymodule_menu() {
  $items = array();
    $items['domain_redirect'] = array(
    'page callback' => 'domain_redirect',
    'type' => MENU_NORMAL_ITEM,
    'access arguments' => array('access content'),
   );
  return $items;
}



function domain_redirect() {

switch ($_SERVER['SERVER_NAME'])
{
  case "campaign.com":
    $goto = "node/22";
  break;
  default:
    $goto = "/";
}

    drupal_goto($goto);
}

Then set the frontpage to domain_redirect.