Welcome Guest | Login

Emulate mod_userdir with .htaccess & symlinks

Hi,
which is the correct way to develop a multiusers site in my hosting plan? I'd like to emulate mod_userdir urls results with "~", but i wouldn't like to use subdomains.

For example:

RewriteEngine on

RewriteBase /
RewriteRule ^~([^/]+)$ ~$1/ [R,L]
RewriteRule ^~([^/]+)/?(.*) users/$1/$2 [L]
username@hostname [~]# cd public_html
username@hostname [~/public_html]# ln -s ~/users ~/public_html/users
http://www.mysite.com/~username
Is this the correct way?
If yes, i'd like to hide the path "users" from Apache listing directories. Infact if i go to http://www.mysite.com/~username/somedir/ and then i turn up directory level the url change to http://www.mysite.com/users/username/ .
There's some way to keep "~" in the url and hide "users" emulating mod_userdir ?

Thank you and excuse my bad english...

2008-04-05 03:14 PM

ZobaZ - web design & sounds
Hi Zobaz, if I'm understanding you correctly you wish you have

domain.com/~username

rerouted to (but keeping it the same in the address bar)

domain.com/users/username


Wouldn't that be:

RewriteRule ^~([^/]+)$ /users/$1 [R,L]

?

2008-04-05 09:15 PM

Thanks William,
your answer (and my search of solutions in the last few hours..) suggest me that there's no way to emulate mod_userdir urls in my hosting plan...

With your solution i'll show "users" in the address bar, but i don't want to show that. And replacing [R,L] with [L] it's the same.. People know ever that theirs documents are inside "users" directory, but i want hide this information everywhere (address bar, bottom bar, and also domain.com/users/username should return error 404 ...), like with mod_userdir solutions...

Thank you.

2008-04-05 09:47 PM

ZobaZ - web design & sounds
Doesn't

RewriteRule ^~([^/]+)$ /users/$1 [L]

leave the URL as

domain.com/~user

so the visitor never knows that the files are being served from /users/ ?

2008-04-06 02:43 AM

No, with this:
RewriteRule ^~([^/]+)$ /users/$1 [L]
or this:
RewriteRule ^~([^/]+)$ users/$1 [L]
the URL domain.com/~user change to domain.com/users/user .

With this:
RewriteRule	^~([^/]+)$    ~$1/  	[R,L]

RewriteRule ^~([^/]+)/?(.*)  users/$1/$2 [L]
the URL domain.com/~user change to domain.com/~user/ , and that's ok.
But if i navigate through directories using Apache listing directories, the URL mantain "~" only until i move down a directory level. When i move up a directory level, clicking the Apache link "Parent Directory", the URL change to domain.com/users/user/dir1/ .

Thanks anyway, hi!

2008-04-06 06:24 AM

ZobaZ - web design & sounds
Moving up and down dir levels seems strange to me.  Are you navigating through apache dir pages?  You can just put index.html files in there if you want to prevent users from seeing your directories.  You can setup a redirect so that domain.com/users/user gives a 404 and it should help.

2008-04-06 03:39 PM

Thanks William,
today i've resolved my problems anyway...

Congratulations for your services on hostingrails! You are very quick, helpful and professional. In Italy we don't have such services...

Still one question: FXP (file transfer from server to server) is enable on hostingrails?

2008-04-06 04:03 PM

ZobaZ - web design & sounds
Hi Zobaz,

Currently FXP is disabled on our servers. Instead you can use the scp command to copy files from one server to another.

2008-04-06 05:21 PM

wow! i didn't know this command! fantastic...
bye

2008-04-06 05:37 PM

ZobaZ - web design & sounds

Hello Guest! In order to post you must be an active client with us, please log in or sign up.