0

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"
    )
}
3
  • 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, 2010 at 10:43
  • @pacey ok, please, suggest me the correct tags
    – aneuryzm
    Nov 8, 2010 at 10:53
  • currently I think the problem is based on lighttpd and redirect
    – pacey
    Nov 8, 2010 at 10:59

1 Answer 1

0

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.

12
  • @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 ?
    – aneuryzm
    Nov 8, 2010 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 ?
    – aneuryzm
    Nov 8, 2010 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 "?"
    – aneuryzm
    Nov 8, 2010 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, 2010 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, 2010 at 10:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .