Migrating site with tilde URL (public_html) mapping


#1

Hi

I have a site which has URLs like http://example.com/~username/ and I would like to move it to dreamhost.
Is it possible to host those pages without needing to remove the tilde character?
Maybe with some fancy rewriting or just simply naming the folders “~username”?
Of course every such folder has it’s own user and password for ftp uploading to the site.
I have not yet a dreamhost site, so I can’t test for myself.

Greetings
Georges


#2

Yes and no. Yes, but it takes a big of backend “patching” that a beginner really shouldn’t do.
You have to:

  • Create a directory called ‘public_html’
  • Create a new user by the same name as your old server
  • Point their home directory to the directory ‘public_html’ resides in.

However, you really don’t want to do that. ~username URLs are concidered “newbie” URLs. If you got a domain account, use a domain name. Yes, that means a lot of file changing, but it’s the proper way of doing it.

As for your “patch” job question:
You can’t create a ~ directory and go from there. ~ has a special meaning in Unix meaning “home”. Ie: ~username is “home of username”. Then Apache searches for a default folder of “public_html” for your HTML files.


#3

~username URLs are concidered “newbie” URLs.

By whom? This is the standard format for user account web space on any Apache server. Look around a little and you’ll actually notice that, if anything, the “newbies” tend to register domains while the older, more experienced and technical users often keep their tilde-username sites. Yes, this is a gross generalization, but your statement is absurd.

If you got a domain account, use a domain name. Yes, that means a lot of file changing, but it’s the proper way of doing it.

If anything, the aforementioned user space is the “proper” way to host user sites, not registering an entirely new domain name or creating a subdomain for them.

To the original poster: How many users are we talking about here? I’ve done it for a few people, including myself.

  1. Create user accounts ((S)FTP or shell, depending on what level of access their old accounts have) for each user you want to migrate. If your lucky, their usernames will be available. All but one of mine were.
  2. Via SSH, create a web directory in their home directory. Name it public_html if you want, but it can really be anything.
  3. Back in the panel, create aliases for each user. Choose the appropriate domain in the drop-down list and make the URL path “~username” (without the quotes, obviously). On the next page, choose the user from the list and complete the path to the web directory you gave them, “public_html” or whatever. Note that the ~username alias should be their old username; it does not need to match the username on the DH system as long as it’s pointing to the right place.

That’s it, tilde sites will now work. You may experience some CGI brokenness doing this. I didn’t run into it with my users, but the panel will warn you about it.

Another method to provide userspace would be to follow steps one and two above, then create a /users subdirectory on your domain. In there, create symlinks for each user to their public_html folder. Then, in the .htaccess file for the domain, use mod_rewrite to rewrite /~username to /users/username.


If you want useful replies, ask smart questions.


#4

If anything, the aforementioned user space is the “proper” way to host user sites, not registering an entirely new domain name or creating a subdomain for them.

Guess it depends on what you mean by “user site.” Someone hosting a site with a ~username for professional purposes is demonstrating a “newbie” move.


#5

Who said anything about professional sites? I know it doesn’t seem like it these days, but some people do actually use the web for non-commercial purposes.

“User site” means exactly what it sounds like: personal web space. It wasn’t so long ago that very few personal sites had their own domain. Tilde-username sites were the norm, even for those who did own their own domains.


If you want useful replies, ask smart questions.


#6

By whom? This is the standard format for user account web space on any Apache server. Look around a little and you’ll actually notice that, if anything, the “newbies” tend to register domains while the older, more experienced and technical users often keep their tilde-username sites. Yes, this is a gross generalization, but your statement is absurd.

The sites, as I’ve seen it, have a migration in URLs.
First it was: domain.com/SiliconValley/3178/
Then it was: domain.com/~username
Then it was: username.domain.com
and ultimately: www.username.com

It’s how sites migrate up. Let me put this a better way, maybe it’s time for the OP to “migrate up” on the URL latter?

Having a domain name is more than just ease, but also has some stature on the internet and definatly has it’s share of “brag rights” amongst your friends that are unable to afford their own (albit extremely rare these day).

[quote]If you got a domain account, use a domain name. Yes, that means a lot of file changing, but it’s the proper way of doing it.

If anything, the aforementioned user space is the “proper” way to host user sites, not registering an entirely new domain name or creating a subdomain for them. [/quote]
If he own a domain, why do you suggest him to use ~username? The proper way of doing a site is to do it at the root of a domain. That’s why I said If you got a domain account. Even if it’s just http://username.dreamhost.com/, you really don’t want to go back to ~username.


#7

[quote]Who said anything about professional sites? I know it doesn’t seem like it these days, but some people do actually use the web for non-commercial purposes.

“User site” means exactly what it sounds like: personal web space. It wasn’t so long ago that very few personal sites had their own domain. Tilde-username sites were the norm, even for those who did own their own domains.[/quote]
If you read the OP’s post, you can see that what he’s asking is a “patch job” so he doesn’t have to go through all his files and change all his links.

Admirable and quite understandable. But he’s going to come to the point soon or later. I’m suggesting he do it now instead of the “patch job” he’s wanting.


#8

Who said anything about professional sites? I know it doesn’t seem like it these days, but some people do actually use the web for non-commercial purposes.

Who said anything about “user sites?” The initial post doesn’t contain enough information to know if it’s a personal or professional site.

“User site” means exactly what it sounds like: personal web space.

“User” does not, in any way, denote “personal.” I host sites for both personal users and professional users.


#9

thanks kchrist for the hint with the aliases that’s going to work fine.

And to guice calling ~urls newbies I say this: I have about 20 years experience in unix and I have been on the Internet almost from the beginning. No newbie here. I eat mod_rewrite for breakfast :slight_smile:

I own my own .com domain, and I have given friends webspace under that. And I have done this with tilde. If I move the whole thing over to dreamhost, who will change on the whole internet the addresses (e.g. remove the tilde) for my friends homepages?

Georges


#10

I own my own .com domain, and I have given friends webspace under that. And I have done this with tilde. If I move the whole thing over to dreamhost, who will change on the whole internet the addresses (e.g. remove the tilde) for my friends homepages?

Find & replace on the site itself. Then can’t you use mod_rewrite to still display the pages if people go to ~username? Or even a redirect? 303?


#11

I think you’re making an awful lot of assumptions here. This really boils down to the question of why someone would force all their users to change their URLs unnecessarily.

The original poster obviously wants to preserve existing URLs for his users; I’d guess that’s so all the links and bookmarks they may have out there don’t break, but really, we don’t know why and it’s not really our concern.

I’d say not forcing this change is a good thing. If his users want to change their URLs, they can choose to on their own. This is why I still have some tilde-username sites on my own domain, and redirects for others. I don’t understand why you insist that “he’s going to come to the point soon or later”. Why would he? I’m not aware of any inherent time limits on URLs.

For myself, I had a tilde-username site on my own domain for many years because I was running my own servers. When you’re doing this, and have given accounts to other people as well, the most natural way to set things up is for everyone to have ~username sites. The root site of the domain had a little information about the operation, services I was running, and a list of links to current users. No additional domains required. These users (including myself) were all, by definition, users of this domain/network/servers. This was before vanity domains became popular and it was years before I was ever asked to host additional domains, although there was no reason I couldn’t have from the beginning.

The status heirarchy you posted is strictly your own opinion. In fact, it used to be commonly considered a status symbol to have a site at a well-known existing domain (see The WELL, for example, and all the user sites they still host). But most people I know assign no such status based on something as unimportant as personal web site URLs.

EDIT: Well, the OP posted a follow-up at the same time I was posting this, so now we do know his reasons, which were just as I assumed.


If you want useful replies, ask smart questions.


#12

The initial post doesn’t contain enough information to know if it’s a personal or professional site.

Well, we’re both making assumptions then, aren’t we?

I think we’re talking in circles here. Tilde-username sites (ie, “user sites” in Apache parlance) are traditionally personal sites, which is why I assumed the original poster was talking about personal sites. Yes, businesses bigger than the single-person-selling-crafts-from-home type of thing usually have their own domains, which is another reason I assumed that the user sites in question were personal.

Anyway, this is all completely irrelevant to the matter at hand.


If you want useful replies, ask smart questions.


#13

[quote]You have to:

  • Create a directory called ‘public_html’
  • Create a new user by the same name as your old server
  • Point their home directory to the directory ‘public_html’ resides in.[/quote]
    This won’t work anyway, since UserDir isn’t set in the httpd config and can’t be set from .htaccess (try it - you’ll get an internal server error).

You might be able to get it to work with mod_rewrite - from the perspective of an HTTP request, there isn’t anything special about the tilde. You can’t just create a ~ directory, true (well you could if you wanted, but it wouldn’t do what the OP wants to do), but that is pretty much irrelevant to this discussion.

I did some quick tests, and you could do something like this (in the domain’s .htaccess file):

RewriteEngine on
RewriteRule ^~([a-z])/(.)$ $1/$2

(a plus would be better after the [a-z] – the forum somehow won’t reproduce either a literal plus sign or +

(put a [R] at the end of the second line to redirect people to the new URL)

Take this with a grain of salt - I’m not a mod_rewrite expert, and you might need to adapt it a little for your needs.

That would take a request like http://example.com/~foo/bar.html and map it to example.com/foo/bar.html (you couldn’t easily give FTP users access to a subdir of your main dir, but you could make a symlink to a subdir of their home dir, e.g., “ln -s /home/otheruser/public_html /home/youruser/example.com”. Alternatively, you could redirect to http://foo.example.com/bar.html (with one subdomain per user).

Anyway, you might not be able to get it to work 100% the way you want, but I think it’ll be possible to do some magic to get this to work. I’d personally suggest sending a redirect so that you can start the process of moving users away from the “~username” syntax.


#14

Well, we’re both making assumptions then, aren’t we?

I never made the assumption it was a professional site. I was just pointing out that your debunk of the original reply made the assumption it was a personal site.

Anyway, you’re right, it doesn’t matter. Now we have more info and the user is just supplying personal directories on a given site.

Tilde-username sites (ie, “user sites” in Apache parlance) are traditionally personal sites, which is why I assumed the original poster was talking about personal sites.

That’s enough of a generalization that it’s not a safe assumption to make.

I just googled to see if there was anything interesting out there on this topic. I found this: http://www.cs.tut.fi/~jkorpela/tilde.html


#15

whoa, it’s not? doh. I just assumed it was since it’s on by default. My bad.


#16

I just googled to see if there was anything interesting out there on this topic. I found this: http://www.cs.tut.fi/~jkorpela/tilde.html

I hope the author is not unaware of the irony in this.


If you want useful replies, ask smart questions.


#17

I will probably go the mod_rewrite way, sending a redirect to a non-tilde dir.

Georges


#18

RewriteEngine on
RewriteRule ^~([a-z])/(.)$ $1/$2

A better RewriteRule might be:

RewriteRule ^~([-_a-z0-9]*) /users/$1 This allows for users with digits, hyphens, or underscores in their username, and also for URLs entered without a trailing slash. I added /users to the target URL so that, if taking this approach, user directories can be cleanly and logically separated from subdirectories belonging to the root site.


If you want useful replies, ask smart questions.


#19

I hope the author is not unaware of the irony in this.

He is aware. In the article he cites an example and gives the URL of the article.

Anyway, I’ll quit derailing the subject. Sounds like a good solution has been found.


#20

I do have to ask, what’s wrong with just using a third level domain for your users? That way you don’t have to rely on mod_rewrite.