Posted by jlane on April 19, 2010 at 2:24am
I don't know if this is the best place to ask this question, but its worth a shot. I have helped develop a site for a non-profit here in Colorado. The site is close to being ready for production, but the powers at be are changing the domain name of the site. So my question is this... does anyone have any recommendations on how to handle this change? I think its more complicated than just point the new domain name and changing the site name in the site configuration page.
Thanks,
JL

Comments
No, it's really that easy. At
No, it's really that easy.
At worst you may have to change the $base_url variable in your settings.php, but it's unlikely that the other domain was ever coded into that file.
More of a trouble is when you have an established site and you have to update everything for all the search engines and whatnot.
Another trouble would be if people (foolishly) hard-coded the old domain into all the links on the site. Then you'd have to go through and change them all. Hopefully that's not the case for you.
Hard coding goodness
You mean you're not suppose to hard code all URL's in Drupal! LOL
Thanks for the quick reply. I was hoping that it would be that easy.
Do not fear mistakes - There are none.
Well that depends
If you have hand coded the URL in parts of the site (hopefully you have not), that may break some of your links. If you think that's an issue, you could cover your arse by adding/modifying your .htaccess file which should be placed in your webroot's directory.
With the code below in the .htaccess file, it would tell apache to automatically/permanently rewrite http://www.old-domain.com/link-to-some-page.html into http://www.new-domain.com/link-to-some-page.html
I haven't done this in a while but It might look something like this...
# Turn on the rewrite engineRewriteEngine on
# If hostname is non=blank
RewriteCond %{HTTP_HOST} .
# and hostname is not desired canonical domain
RewriteCond %{HTTP_HOST} !^www.old-domain.com
# redirect to canconical domain
RewriteRule (.*) http://www.new-domain.com/$1 [R=301,L]
"Education is a progressive discovery of our own ignorance." ~Will Durant
Web: http://www.ilaniam.com
Hard coding goodness
Thanks Sendben, I'm going to poke around to see if any existing nodes have hard code urls. If they do I will go your route.
Thanks again all!
JL
Do not fear mistakes - There are none.
Interesting timing on this question
I am building a website for my wife and she is thinking about changing her domain name. One point that has not been mentioned yet is the issue of a domain being hosted under a multi-site, single code base configuration, which is the case for my wife's site. I am currently on a shared server, which is set to point to my domain name. I have pointed my wife's domain to my nameserver. The issue here is that my wife's site is located under the "sites" folder, which is located in the "web root." So, in this case, I would need to change the name of the subdirectory. What I will probably end up doing, if she does change her domain name, is to also use a rewrite rule in the .htacess file so that a call to her old domain name will still point to the new domain name, since it's paid up for a year anyway and the search engines have already found it. Here is what the rewrite rules look like to direct to http://newdomain.com:
RewriteCond %{HTTP_HOST} ^www.olddomain.com$ [NC]RewriteRule ^(.)$ http://newdomain.com/$1 [L,R=301]RewriteCond %{HTTP_HOST} ^olddomain.com$ [NC]RewriteRule ^(.)$ http://newdomain.com/$1 [L,R=301]RewriteCond %{HTTP_HOST} ^www.olddomain.com$ [NC]RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]I have written a bunch of separate statements that can be combined into one using an [OR] operator on the conditions, but that is starting to stretch my understanding of doing things on Apache and I don't want to mislead anyone; I don't know what the [NC] operator does. If anybody would like to comment on how to do it properly using the [OR] syntax, that would be great.
Another thing for you to keep in mind, is that you need to ensure that mod_rewrite.c is installed and that the RewriteEngine is on. Just so you know, a .htaccess file comes with the Drupal install. It should be in your "web root" directory on your web server.
Vegantriathlete, can you clarify?
I'm not sure that I understand, are you using a single Drupal install to run multiple websites? Or do you just have a shared hosting account on which you want to have multiple sites?
Either way, I think this may solve your problem if you want to have different domains resolving to different sites on the same shared hosting account.
Looking at your site, it looks like you're running cPanel.
Locate the "Addon domains" icon in cPanel. That will allow you to specify additional domains if your web host allows it. You may have to purchase the addon domain slots depending on your host.
Make sure that wife-domain1.com's DNS resolve to the your host's DNS (just like your primary domain for the account.)
In "Addon domains", you can specify a custom directory within your webroot for each addon domain....
New domain: wife-domain-1.com
Document Root: webroot/sites/ (often your webroot is public_html or httpdocs)
(Optional) You would repeat steps 1-2-3 for wife-domain2.com if she decides to go for a new name. Each domain is an addon slot, make sure your host allows that many addon slots...
(Optional) If you go for wife-domain2.com and you want wife-domain1.com to redirect to it, then do this.....
Place a .htaccess file inside your addon domain's document root (webroot/sites/.htaccess)
Use the same syntax I described in my previous comment in this thread. where old-domain.com is wife-domain1.com and new-domain.com is wife-domain2.com
The htaccess file in webroot/sites will govern your wife's domains. The htaccess file in the webroot/ will only act upon your primary domain.
PS: If you have a lot of backlinks to your wife's old domain, you may want to keep it active for search engine rankings.
Hope this helps
"Education is a progressive discovery of our own ignorance." ~Will Durant
Web: http://www.ilaniam.com
I'm not having any problem at all
@sendben
Thanks for your response. I've actually got things under control. I have a single install of Drupal, under which I'm running two websites: my own, and my wife's. Everything is working fine. Right now, I am doing all my rewrite work through the .htaccess file that is located in the "web root",i.e. the Drupal install root, which in my case is called /public_html (or www, which is just a mirror). /public_html is what is located under my domain name. So, in effect, my wife's domain is a subdomain of my domain; it just doesn't have to be accessed that way. Nobody has to know any different. They get to my wife's site by typing wifesdomain.com. (If you are curious for the specifics, I can tell you her domain name. I just don't want people to think I am spamming the thread. Obviously, you have visited my user profile to discover my personal website. Thanks for stopping by. I hoped you like it :-)
You are right that I am using cPanel. My webhost allows me to host an unlimited amount of domain names. Mine happens to come for free with my web hosting package. My wife registered hers separately. I did use the addon domain feature.
So, my site runs directly from /public_html. My wife's has her own settings.php located under /public_html/sites/wifesdomain.com.
The point I was trying to make in my original post is that if my wife decides to change domain names, I will need to rename the folder to /public_html/sites/wifesnewdomain.com. Then I would take the wifesdomain.com and use the rewrite condition and rules to point it to wifesnewdomain.com.
Use a symlink?
I know you're not having problems, but I thought this was an interesting point to throw in...
Rather than renaming the folder, can you not use a symlink instead? If you're using Drupal's multisite features you can do
ln -s ./public_html/sites/wifesdomain.com ./public_html/sites/newwifesdomain.comSo you'll end up with both URLs working. I often do this as I develop on one domain and deploy onto another, so I simply create a website under public_html/sites/projectname then on the test site I have
public_html/sites/projectname.testdomain.com -> public_html/sites/projectnameand on the live site I have
public_html/sites/www.projectname.com -> public_html/sites/projectnameBecause the 'main' sites folder is just 'projectname', that is what's stored for e.g the /files/ folder in Drupal, so when I go live it all just works with the same path as before.
Using symlinks does rely on you having certain access to the shell, which you might not have.