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"
    )
}
aneuryzm
  • 1,614
  • 5
  • 25
  • 40

1 Answers1

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.

pacey
  • 3,833
  • 1
  • 15
  • 31
  • @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 08 '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 ? – aneuryzm Nov 08 '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 "?" – aneuryzm Nov 08 '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 08 '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 08 '10 at 10:41
  • @pacey Ok, I wrote "it doesn't work", but in the same line I added it is because the appended argument, right ? Thanks for the last tip, however isn't "%20" to replace spaces between words ? I actually don't have any space: www.website.com/?q=content/specificpage – aneuryzm Nov 08 '10 at 10:51
  • %20 - you are right, is the url-encoded ASCII#32 (the space). I wanted to give you an example of URL encoding and %20 is recognizable very easy. You might want to try: `http://www.mywebsite.com/?q=content%2Fspecificpage` – pacey Nov 08 '10 at 10:57
  • @pacey Ok, so I'm now using %2F instead of "/" and I made explicit the php page in the url. Still it doesn't work.. I've updated my question with the latest version of my configuration file. – aneuryzm Nov 08 '10 at 11:09
  • Could you give me a brief description what how the result you are getting differs from what you expect. – pacey Nov 08 '10 at 12:17
  • @pacey It goes to the website home page http://www.website.com/index.php (I guess it doesn't consider the arguments after "?") – aneuryzm Nov 08 '10 at 15:05
  • It seems so but according to the [Docs:ModRedirect](http://redmine.lighttpd.net/wiki/1/Docs:ModRedirect) It should be working. You should also set `url.redirect-code = 301` or `302` – pacey Nov 08 '10 at 15:47
  • @pacey So, I've tried to redirect another domain on my server and the configuration code works very well. I'm now wondering why the other domain doesn't work... I've transferred these domains to my hosting.. and I have control only on one of them. – aneuryzm Nov 09 '10 at 11:12