By moshub on
I'm looking for a way to use two domain names for the same drupal site. how can i make it happen? any configurations to the settings.php file??
thanks
M
I'm looking for a way to use two domain names for the same drupal site. how can i make it happen? any configurations to the settings.php file??
thanks
M
Comments
If you can make the second
If you can make the second domain also point to Drupal's installation directory, then Drupal can handle it with an additional directory under /sites.
/sites/www.example1.com/settings.php containing a $db_url and a
/sites/www.example2.com/settings.php containing the same $db_url
Google ratings specialists may tell you that Google will penalize this setup (assuming you care).
The best way to do this
The best way to do this would be to have one domain mirror the other, or just have one domain jump to the other.
Use Apache virtuals and a redirector
Hi Moshub --
We often have the case where our 'real' name is www.example.com but we have some other domains we want to get to the same place as 'aliases', perhaps www.goodexample.com and www.example.net.
What we do is configure Apache with name-based virtual hosts: the second one is the real name www.example.com; the first one is the 'catcher'. http://httpd.apache.org/docs/1.3/vhosts/name-based.html
You point all the DNS at the same place; in our case we put the primary with the A record and the others with CNAME:
When a client makes a request to Apache for a virtual server which isn't matched in its list of hostnames, it gives you the first one. So we make it so that whatever is requested, you get redirected to the primary. We do it with index.php which just puts out a redirect:
header("Location: http://www.example.com");We also redirect the error pages.
(If you're not able to make a default server, you can still just put little redirectors in the data directories of the alias sites or even have two real servers. If you want to make it clever you could do geolocation on the incoming request and direct them to a suitable regional host.)
We do it this way so that even if you come in by IP address you get redirected, and it shows as the primary name in the client's browser which means their bookmarks will be good.
Hope that helps.
Best regards,
J.
PS. If what you meant was actually having two domains point to the same documents, I think you simply ensure that Apache has the same document root, and the Drupal installation uses sites/default
rather than www.example.com. I've never run a site like that in earnest, but it certainly seems to work. I believe you can also use the Apache server-alias directive. And lastly I think you can do it by having sites/www.example.com and sites/www.example.net have the same database, but I haven't tried this.