Forum Moderators: phranque

Message Too Old, No Replies

tilde or not tilde, show this user's page

how to make mysite.com/myuser work like mysite.com/~myuser

         

alexis

1:20 pm on Apr 21, 2006 (gmt 0)

10+ Year Member



My server is setup to allow easy creation of new web users. It does the old trick of making /~myuser redirect to /var/www/vhosts/mysite.com/web_users/myuser

I find the tilde a bit odd to tell people when I give a URL as most of them don't know what tilde is.

I looked at the httpd.conf to find as only clue these lines:

<IfModule mod_userdir.c>
UserDir /var/www/vhosts/mysite.com/web_users
</IfModule>

I usderstand that this tells the server to look for a webuser whenever a tilde is encountered after mysite.com/ but I can't find the place that specifies that says the tilde is THE magic character. I would prefer no character at all so that accessing mysite.com/myuser would show the same thing as mysite.com/~myuser.

I also looked into mod_rewrite but since the virtual host's public directory is /var/www/vhosts/mysite.com/httpdocs and the webuser directory is /var/www/vhosts/mysite.com/web_users, mod rewrite won't be able to link those 2 directories together.

Any clue how this could be done?

jdMorgan

2:30 pm on Apr 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> I usderstand that this tells the server to look for a webuser whenever a tilde is encountered after
> mysite.com/ but I can't find the place that specifies that says the tilde is THE magic character.

The tilde is defined by mod_userdir -- it is hard-coded as far as I know. It is a 'standard' by default, and has been in use for many years on 'free' webhosting services.

You could always call it a 'squiggle' or tell them "It's the Shift-` key, usually at the top-left corner of the keyboard, to the left of the number '1' key."

> I would prefer no character at all so that accessing mysite.com/myuser would show the same thing
> as mysite.com/~myuser.

But then the problem arises of "how do you tell the server which subdirectories are 'user' directories, and which are your 'system' directories?" You could have a user try to sign up as "w3c" and blow up your compact privacy policy, or sign up as "images" or "cgi-bin" or some other common web site subdirectory name...

An alternative method would be to replace the mod_userdir function with mod_rewrite, moving all user directories to a subfolder of /httpdocs, say, /httpdocs/users. But even if you did that, you'd still have to tell your users to prepend *something* --the "/users" subdirectory name in this case-- to their username, so that the server would know where to look for their files.

Another method would be to let them use subdomains to access their filespace -- as long as you plan to let them use any and all subdomains except for "www" (Otherwise, you'd have to check for 'reserved' subdomains at several places in the code used to implement this).

Jim