domain.com/~user ---> user.domain.com

domain.com/~user ---> user.domain.com

am 12.11.2007 17:33:57 von policleto

Hello,

I am new to this forum (found it via Google). Please forgive that I
just snow in like that, but I have a rewrite problem, which
a .htaccess Guru can maybe solve in a few minutes. - I wasted already
some days, but it still doesn't work.

Want I want to do is the following:

If someone accesses http://user.domain.com/ he shall be redirected to
http://www.domain.com/~user/

Similarly, all accesses under the subdomain shall be redirected, too,
e. g. http://user.domain.com/dogs/cats.html should retrieve
http://www.domain.com/~user/dogs/cats.html

The subdomain entry should remain in the URL field of the browser, i.
e. the redirect should be "hidden".

The reason why I need this, is that, when I create a user web/FTP
account, the URL to it is http://www.domain.com/~user/, and I would
like to assign a http://user.domain.com/ subdomain to them.

Let me give you the background of the directory structure:

http://www.domain.com/ points to the path:
/home/www/web12/web

http://www.domain.com/~user/ points to the path:
/home/www/web12/user/domain.com_user/web
and
http://user.domain.com/ should points to the same path.

So basically, the .htaccess file would have to direct HTTP file
accesses http://user.domain.com/* to http://www.domain.com/~user/*
respectively.

But as the entry in the URL field in the browser shall not change, one
would have to work with the paths, if I understand it correctly?

Does somebody know a solution to this problem (rewrite condition &
rewrite rule)? I'd hang his picture up in my living room.

Kind regards,
Antonio.

Re: domain.com/~user ---> user.domain.com

am 12.11.2007 17:55:28 von Rik Wasmus

On Mon, 12 Nov 2007 17:33:57 +0100, wrote:

> Hello,
>
> I am new to this forum

This is usenet, not really a forum...

> (found it via Google). Please forgive that I
> just snow in like that, but I have a rewrite problem, which
> a .htaccess Guru can maybe solve in a few minutes. - I wasted already
> some days, but it still doesn't work.
>
> Want I want to do is the following:
>
> If someone accesses http://user.domain.com/ he shall be redirected to
> http://www.domain.com/~user/
>
> Similarly, all accesses under the subdomain shall be redirected, too,
> e. g. http://user.domain.com/dogs/cats.html should retrieve
> http://www.domain.com/~user/dogs/cats.html
>
> The subdomain entry should remain in the URL field of the browser, i.
> e. the redirect should be "hidden".

> So basically, the .htaccess file would have to direct HTTP file
> accesses http://user.domain.com/* to http://www.domain.com/~user/*
> respectively.

Something like this (untested, never worked with users like that..)?

RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^(.*+)\.example\.com
RewriteRule ^(.*)$ /~%1/$1 [QSA]
--
Rik