Map new domain


#1

Maybe “map” isn’t the right word. But it sounds techie.
I am building a website for a business partner. Unfortunately, the original domain name we decided on is encroaching on someone else’s copyright, so he purchased - through Dreamhost - a new domain name. The domain only shows up under “Domains -> Registrations” from the main DreamHost panel.
How can I map the new domain to the current physical location I access via ftp? Or is it preferable in DreamHostland to utilize the …/newdomain.com/[here are my files] directory and redirect from the old site? Given a choice, I prefer the latter.
Thanks,
Matt
current domain:
http://www.climbthecliffs.com/
future domain:
http://www.ctrockgym.com/


#2

As you’ve guessed, there are a few ways of handling this:

  1. You could simply map your new domain to your old domain’s web directory. First, go to “Domains>Manage Domains” in the panel and edit the hosting for your old domain. Note what the “web directory” is for the old domain. Go back to the “Domains>Manage Domains” page and “Add new Domain / Sub-Domain” for the new domain. Specify the “web directory” of the old domain. Wait a bit for DNS to propagate and you’ll be up and running in the new domain if all you have is static content. After you’ve confirmed that the new domain works, you can change the old domain be a redirected domain instead of a fully hosted domain.
  2. As a second step to this, you could rename the web directory to have the same name as the new domain. This will eliminate future confusion.

Note that this only really works well if you have a static site. A dynamic site will almost always have some configuration that specifies the domain it’s running in. This helps to generate links and such. In this case you’ll have to edit those configuration variables by hand before the site will work.

Would this work for you?

Free unique IP and $67 off with promo code [color=#CC0000]FLENSFREEIP67[/color] or use [color=#CC0000]FLENS97[/color] for $97 off. Click here for more options


#3

I added the new domain as you suggest, but I let use its own subdirectory. I’ll ship the files from the old site to it and when I think it is fully propagated I’ll tell DreamHost to redirect the old site.
The tricky part is knowing that the “Add new Domain / Sub-Domain” is for domains I already own.
Thanks for you help.
Matt


#4

Sounds like an even better plan! I got hung up on the original idea of reusing the web directory, but if you can make a copy to the new web directory, that’s fantastic.

BTW, do you use the shell or do you just use sftp or ftp? I ask because if you’re a shell user you can easily just copy the files in the shell directly on your DreamHost server.

Finally, I just wanted to make sure you know that you can control the redirection of your domain to the new site. (You said “I’ll tell DreamHost” and I wasn’t sure if you intended to use the panel operation for configuring this) :slight_smile:

Free unique IP and $67 off with promo code [color=#CC0000]FLENSFREEIP67[/color] or use [color=#CC0000]FLENS97[/color] for $97 off. Click here for more options


#5

Generally I use SmartFTP to download/upload files. Given that I have to move the whole site I’ll try the shell route.
As for the site redirection, under Manage Domains there is an option to have a site redirected. I figured on using that. Which brings up a question: if I use DreamHost’s redirect and someone has bookmarked "http://www.olddomain.com/somepageotherthanindex.php," will the request be redirected to simply “http://www.newdomain.com”? That’s fine with me if it is the case.
Thanks,
Matt


#6

I think that’s right (on the redirection). I think you need to write your own mod_rewrite directives in order to redirect every page to the corresponding page on your new site. I’m not 100% sure on this, though.

Free unique IP and $67 off with promo code [color=#CC0000]FLENSFREEIP67[/color] or use [color=#CC0000]FLENS97[/color] for $97 off. Click here for more options


#7

Fortunately the site is small enough right now that I don’t mind blanket-redirecting everyone to the new url index.php. I’m working on it right now, so I’ll let you know if I run into something.
Matt


#8

I did think of one thing: I have a MySQL db attached to the old domain. Can I easily move it to be accessible under the new domain?
Matt


#9

You only really have one MySQL server, though you can refer to it by any name you choose. You can either leave it or create a new name and change your scripts to refer to the new name. Nothing really needs to be “moved”.

Free unique IP and $67 off with promo code [color=#CC0000]FLENSFREEIP67[/color] or use [color=#CC0000]FLENS97[/color] for $97 off. Click here for more options


#10

I’ll partly answer my own question: mysqldump. New second question: must I create the tables as they are in the old db, or does mysqldump also dump structure?
While you answer, I’ll research.
Thanks,
Matt


#11

Looks like it creates the tables, too. I’ll give it whirl.
Matt


#12

Looks like I just dumped my database to itself and wiped it out. foo. Guess the fact that I specified a different server didn’t matter.
So, new question: does DreamHost automatically back up the databases?
Power + Stupidity = powerful stupidity.
Matt


#13

Yet again, answered my own question: “restoredb” from the “manage sql” page. I only lost a few rows.
Word to the wise: backups are there, but can be > 12 hours old, so beware. And for windows users: Unix deletes first then assigns, so never put something you cherish on the “left” (assignee) side of an operation.
BTW - sorry for the myriad posts, but I was in a time crunch and unable to wait to see if I could figure it out myself.
Consider this thread a disjoint tutorial.
Thanks,
Matt
Now, I still have to try mysqldump…


#14

Have you read my earlier post yet? Is there a reason you can’t just reuse the old database with your new site?

Free unique IP and $67 off with promo code [color=#CC0000]FLENSFREEIP67[/color] or use [color=#CC0000]FLENS97[/color] for $97 off. Click here for more options


#15

I was deep in mental retardation when you sent that post. When I first brought up the new site it didn’t see the old database, so I just assumed I needed to move it under the new host name.
So, no, there apparently wasn’t a reason, until I deleted the database. Actually, there wasn’t even a reason then, but I didn’t know any better.
Matt


#16

Oops. Don’t feel too bad, we all have days like that!

You’re on the right track. Keep going and let us know if you run into any additional hitches.

Free unique IP and $67 off with promo code [color=#CC0000]FLENSFREEIP67[/color] or use [color=#CC0000]FLENS97[/color] for $97 off. Click here for more options


#17

Of course there are additional hitches…
Under the old domain everything still works fine. Under the new domain, however, my $PHPSESSID is not finding its way to my processing script.
Here’s what I am doing:
Person visits the page. An included php file starts a session (session_start():wink: and creates a session ID so the calling script can include the session id in the POST data. Form submits to a PHP script which compares the POSTed session ID with $PHPSESSID. If they don’t match, or $PHPSESSID is blank, the form data is not processed.
Suddenly this does not work under the new domain. The $PHPSESSID variable is always blank.
BTW - The goal of the above is to prevent someone from submitting repeatedly (or at all) from anywhere other than my site. Hell if I know that it really is a sound method, but in my limited testing it provided some measure of security. I’ve been meaning to get someone with brains to try and hack it.

Here’s some code:
php script to start session (incldued in index.php):

<?php session_start(); $_SESSION['sessionid'] = mt_rand() . mt_rand(); ?>

index.php starts out like:

<?php include realpath('../../private/sql/session.php'); $sessionId = session_id( ); ?>

$sessionId is populated, yet if I try to write $PHPSESSID to the page it is blank. Naturally, it is still blank when the processing script (form action) is called.

Why would this suddenly not work? Do I have to enable some PHP feature in DreamHost?
Thanks,
Matt


#18

I found one thing: the version of PHP on the new domain defaulted to 5.2.2 instead of 4.4.7. I wonder if that is the issue…


#19

Disco.


#20

One more question to bring this all to completion, at least for now because it is 1:30AM:
If I edit my old (and still) fully hosted domain (climbthecliffs.com) and add the new, fully hosted domain (ctrockgym.com) to the “Redirected” text box is that sufficient to forward climbthecliffs.com requests to ctrockgym.com? It sure looks like that is the way, but when domain changes are concerned, better safe than sorry. I’m playing with someone else’s money.
Thanks again for the support. You guys rock.
Matt