Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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"] =~ "www.mywebsite.com" {
  server.document-root = "/var/www/website/?q=content/specificpage
"
}

or

/var/www/website/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 ?

thanks

Latest Version

$HTTP["host"] =~ "(^|\.)newdomain\.com$" {
    url.redirect = (             
        "^/(.*)" => "http://www.website.com/index.php?q=content%2Fspecificpage",
        "" => "http://www.website.com/index.php?q=content%2Fspecificpage",
        "/" => "http://wwww.website.com/index.php?q=content%2Fspecificpage"
    )
}
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
add comment

1 Answer

up vote 0 down vote accepted

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

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

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

        // matches http://www.mywebsite.com/
        "/" => "http://drupalsite/path/to/your/php/file.php"
    )
}

Please remind, that this requires that www.mywebsite.com 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: www.mywebsite.com 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
show 7 more comments

Your Answer

 
discard

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.