Hello. I have a client that needs me to change the domain/url on his existing drupal site. He wants to continue using the site on the same server that it is hosted, but now having a new domain pointing to it and eliminating the old domain. I plan on having the new domain that he purchased pointed at the original hosting server, but I have to figure out how to change the the path of the Front Page first, I'm sure, or else I don't think I'd be able to get into the user/login page, right? I've seen the original "Front page" under "Site Information", but you can't change that... and I really didn't expect it to be that easy. Any help, as quickly as possible, would be greatly appreciated.

Comments

DanB0328’s picture

Anyone? Come on, this has got to be an easy one that's just slipping by me.

DanB0328’s picture

Seriously. Is anybody out there? I thought this was a community to help each other.

jamesoakley’s picture

People are out there, but that was two follow-up posts within 24 hours. You have to give people time to read things and respond! I see you were also chasing for responses at http://drupal.org/node/983360. The Drupal forums are full of friendly people who want to help, but it isn't a helpdesk. A little patience goes a long way - and it also helps those who try to help if you're able to come back and update on how things went.

To get to your question: It should be as simple as clearing all the caches, and you're away. The only time it's more complicated is if:

  1. You have done a multi-site install, so that your settings file is not in /sites/default but in /sites/example.com. In that case, you'd have to move (or copy) those settings to a folder that will be found on the new domain.
  2. You have links in the text of your site that explicitly refer to the full path. Within the text of your nodes, and in the menus, everything should be relative to the site homepage - link to images using /system/files/image.jpg, link to your contact page with /contact, etc. If you have a link to the contact page that is example.com/contact, then obviously you're going to have to change those links.

Otherwise, it is really easy. I do it all the time when I want to work on a site using a different domain for a development copy. I just copy across the code and the database, clear caches, and the site works.


This signature is currently blank
DanB0328’s picture

Hey James. Thanks for your reply. Sorry about the lack of patience. My client has been breathing down my neck pretty hard about this the last couple of days. I did notice that I have an htaccess file in my root folder that has the following code in it:

Redirect /index.html http://theiroriginaldomain.com/the_folder_it_resides_in/

Do you think this should be changed to their new domain and leave the old folder name? I think we did this to help with some hosting issues and was recommended by the hosting server. I know that when the site is visited now, the folder name does not show up in the address. We fixed that on the server side as well. (It's been a long time since I built this site and I'm trying to recall the process we went through. Oh, and it was my first build in Drupal, so things could be a little screwy.)

Also, I forgot to mention that when I go to "Site Information", at the bottom where it says "Default Front Page", it shows http://www.originaldomain.com/ (not editable) and then a box that is editable that shows index.html. That kind of made me think I had to change something before pointing the new domain at the old site. Thoughts?

Thanks and again, sorry for my crabbiness. It's been a rough couple of days.

jamesoakley’s picture

Hi there

Not to worry - it can be pretty stressful when someone's breathing down your neck.

I'd definitely remove (or comment out) that line from .htaccess. That will only redirect index.html, which wouldn't usually be a page that you'd load in Drupal, so I'm guessing that they client had a non-drupal static site before, and this was to redirect their old home page to the new Drupal site. I wouldn't change it to the new domain - I'd just drop it altogether, at least until everything is working.

You might also want to consider replacing that .htaccess file entirely with the one that comes with Drupal.

Then make sure you've cleared all the caches.

Until the "Site Information" page shows the new domain in that uneditable box, you are still loading the site from the old domain. But I think that resetting .htaccess and flushing all caches should fix that.

Come back here and let me know how you get on once you've tried that.


This signature is currently blank
DanB0328’s picture

So just to get this straight, before I screw anything up, I should do the steps in the order listed below?

1. Remove .htaccess file from their server (viewing hidden files) and replace it with the standard htaccess file that came with Drupal.
2. Point the new domain to the folder that the site is in on their server.
3. Clear Caches under the Performance area.
4. Periodically check the Site Information until the new domain name is there.
5. Make sure site is running correctly.

Just trying to make sure this is as simple as reading Drupal for Dummies or something. (Which I don't own by the way : )

Thanks again!!!!!!

jamesoakley’s picture

Step 4: "Periodically". After clearing the caches, that should happen immediately if you access the site from the new domain.

Also, before you start:

(i) Back everything up (files and database)
(ii) Make sure that the settings.php file for your site is in /sites/default not in /sites/olddomain.com. If it's in the latter, there's an extra step that I'll gladly explain if that's your scenario.


This signature is currently blank
DanB0328’s picture

Okay, so I got the new domain to point to the existing site. I had to point the new domain to the IP address and then change the Primary Domain. That all worked fine, except....

1. Now the css is all screwed up. I am going to try to upload the old css that I downloaded before the change in domain names. Unless that would be incorrect. (Keep in mind, this was a custom site that I had to write a lot of css for and not a standard template.)

2. Under the Site Information, the Front Page URL still reads as www.theolddomainname.com/index.html. This seems to be a problem because anytime I save configuration after changing anything, it tries to go back to the old domain name. ie. Change the Site Information Name, Save configuration, it goes to www.olddomain.com/admin/settings/site-information and shows an error page. If I replace the old domain with the new one in the address bar after this occurs, it shows that the changes have been made. I must have set this somewhere in the beginning, but I can't for the life of me figure out where.

Any thoughts or suggestions? By the way, this site has not been updated in a long time because the said client does not want to pay for updates for anything. Thanks in advance again!

jamesoakley’s picture

Not quite sure what's going on with the CSS. At the very least, you would need to upload any CSS you were using before, but I thought you had already uploaded the entire file system you had been using.

As for the URL keeping reverting, one thing to check: There is an optional setting in settings.php where you can set $base_url to tell Drupal what the root URL should be for the installation. Check if that's there. If it is, get rid of it - it's probably what's confusing things. If it isn't, you could try putting it in there with the new URL and see if that does any good. (That latter approach isn't a great fix, as it's more a hack - you wouldn't have found the reason for the problem).


This signature is currently blank
DanB0328’s picture

Great! The $base_url worked in the settings file. Don't know why I didn't think of that before.

Now the css is tripping me up. I'm hoping not to have to, but I may have to rewrite some of the code. I say that because the weird thing about this is that all of the css files in the css folder are different now. For some reason, it looks like they are creating their own new files. This is so weird. It went from having 17!! css files to 6 when I changed the domain and cleared the cache data. I fear that I may have done something wrong here. At least it's not too bad (not everything is out of place, just some things) and I know I can fix it with firebug, but it is a pain.

Actually, just as a test, I just went and deleted all of the css files and refreshed the site to see what happened. It looks the same on the web, but now there are 3 css files on the ftp server. Crazy. I think I'll just go ahead and adjust some of the code.

jamesoakley’s picture

Do you have a module like Advanced Aggregation enabled? That could cause something like that. If that, or a similar module, is involved, what it's doing is aggregating and compressing the actual CSS files to make the fewer, smaller ones that get served up in the page. If you turn off those settings you should be back to using the actual CSS files again, which makes debugging far easier.

Just a thought


This signature is currently blank
DanB0328’s picture

I don't have the Advanced Aggregator module loaded. Is there another one I should look for that could be doing the same thing?

DanB0328’s picture

Here's what I've done so far. I just disabled Optimize CSS files and Java Script files under the Performance tab. Not sure why those were enabled, but maybe that was the problem, because I then restored the old css files in the ftp manager and then reloaded the site pages and none of the css files changed. However, the css on the actual site wasn't corrected either. Maybe I need to upload the old database, but thought I'd ask before I do that. If so, can I just upload the old zip file, or does it have to be uncompressed?

DanB0328’s picture

Okay, so I think turning off the optimize css and javascript files worked, because the css files in the css folder are not updating themselves anymore. Whew! So now all I had to do was go into the extra.css (that's what I named my main css file) and work with a couple of things to make everything all nice and happy looking again. And no need to reload the database.

I just wanted to say THANK YOU to you guys for all of your help. I am extremely grateful and I hope this helps anyone else that has to go through this. In the end, next time I will know better and build everything more correctly.

jamesoakley’s picture

Glad you got there. Yes - in Drupal 7, CSS optimisation is built into Core, so you did the right thing.

Sounds like you're through the worst. And, as a bonus, you've learnt your way around that particular site somewhat better than you knew before - or at least had a useful refresher!

Anyway, glad to have been able to help.


This signature is currently blank
tjtj’s picture

All URLs on the new site point to the old (development) site. I have explicitly set the base_url in settings.php to the new site URL, and I searched all the files I can think of for the url of my old site. I can only think it is in the database. update.php seems to work and returns links to the new admin and front pages. But thereafter, every link goes to my old site.

I tried all the things listed above I think.

Thanks,
Jim

Diane Bryan’s picture

You need to disable CSS and JS aggregation, maybe also disable specific block caching for views... all these must be done from the OLD domain, if I'm not mistaken.

If you solved it some other way, can you post it here for other users?

Thanks,
Diane

DrupalHack’s picture

To anyone coming across this old thread, remember to change the cookie domain in the settings.php

$cookie_domain = 'YOURNEWDOMAIN.COM';