Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to redirect a domain to a specific section in Drupal. My DNS works, Drupal works.

Creating virtual host on my webserver:

$HTTP["host"] =~ "" {
  server.document-root = "/var/www/website/?q=content/specificpage



didn't work... the issue is that the path includes arguments appended after the "?"

Or should I instead point the new domain to another folder with a php script and forward the user from there ?


Latest Version

$HTTP["host"] =~ "(^|\.)newdomain\.com$" {
    url.redirect = (             
        "^/(.*)" => "",
        "" => "",
        "/" => ""
share|improve this question
You should mention that actually if your DNS Server is resolving the IP correctly this is neither a drupal problem nor something with DNS – pacey Nov 8 '10 at 10:43
@pacey ok, please, suggest me the correct tags – Patrick Nov 8 '10 at 10:53
currently I think the problem is based on lighttpd and redirect – pacey Nov 8 '10 at 10:59
up vote 0 down vote accepted

You should be using lighty's url redirects like this to accomplish that task:

$HTTP["host"] =~ "" {
    url.redirect = (
        // matches
        "^/(.*)" => "http://drupalsite/path/to/your/php/file.php",

        // matches
        "" => "http://drupalsite/path/to/your/php/file.php",

        // matches
        "/" => "http://drupalsite/path/to/your/php/file.php"

Please remind, that this requires that resolves to the IP address of your lighttpd instance.

share|improve this answer
@pacey so i should actually refer to the main domain.. if the first domain change I've to update also this domain in the configuration ? – Patrick Nov 8 '10 at 10:25
Second question: why did you add 3 lines instead of only the first one ? "^/(.*)" I'm actually using reg expressions before: (^|\.)mywebsite\.com$ Is that the same ? – Patrick Nov 8 '10 at 10:28
Third point: by the way it still doesn't work. I guess because it doesn't like the drupal path... it is not a php file, it appends arguments to the url after "?" – Patrick Nov 8 '10 at 10:34
In my example: refers to the domain which redirects to http://drupalsite/[...] (to which the request is being redirected). If any of these addresses change you will have to edit the configuration again. – pacey Nov 8 '10 at 10:35
3rd: "It doesn't work" is not really helping me helping you. URL Parameters have to be encoded like %20. Arguments are to be appended behind a question mark. – pacey Nov 8 '10 at 10:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.