RewriteRule - works for /~user/ but not /user/

RewriteRule - works for /~user/ but not /user/

am 28.10.2003 15:50:20 von dave

have a domain name just for user personal sites.
mod_userdir makes "sites.mydomain.com/~username" work just fine.
user homedirs are in the /www/vhosts/username
mod_userdir correctly pushes ~user into the user public_html directory
UserDir public_html
/www/vhosts/username/public_html

want to provide similar functionality to "sites.mydomain.com/username".

using the below RewriteRule ends up dumping me in the /www directory though
RewriteRule ^/([a-z0-9A-Z\.\-]+)(.*) /www/vhosts/$1/public_html/$2

excerpt from httpd.conf
++++++++++++++++++++++++++++++++++++++++++++++++++++++
..
..
RewriteEngine on
..
..
..

DocumentRoot /www
ServerName webserver.mydomain.com
ServerAlias sites.mydomain.com
RewriteRule ^/([a-z0-9A-Z\.\-]+)(.*) /www/vhosts/$1/public_html/$2

..
..
++++++++++++++++++++++++++++++++++++++++++++++++++++++

comments appreciated.

Dave


------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: RewriteRule - works for /~user/ but not /user/

am 28.10.2003 18:17:02 von Leif W

----- Original Message -----
From: "Dave [Hawk-Systems]"
To:
Sent: Tuesday, October 28, 2003 9:50 AM
Subject: [users@httpd] RewriteRule - works for /~user/ but not /user/


> have a domain name just for user personal sites.
> mod_userdir makes "sites.mydomain.com/~username" work just fine.
> user homedirs are in the /www/vhosts/username
> mod_userdir correctly pushes ~user into the user public_html directory
> UserDir public_html
> /www/vhosts/username/public_html
>
> want to provide similar functionality to "sites.mydomain.com/username".

See http://httpd.apache.org/docs-2.0/urlmapping.html#user .

The purpose of the tilde (~) is to distinguish between a regular directory
or file under the document root, and a user directory. You can't just
remove the tilde and expect Apache to automatically know the differrence. I
see you attempted to compensate for this with a RewriteRule, but that
rewrites the URI sent to the browser, not the filesystem path where files
are read from (if I understand it correctly, still new to rewrite). You'll
need to replace the tilde with something. The example shows the usage of an
AliasMatch, which is keyed off of a /upages directory instead of a tilde.

Leif

> using the below RewriteRule ends up dumping me in the /www directory
though
> RewriteRule ^/([a-z0-9A-Z\.\-]+)(.*) /www/vhosts/$1/public_html/$2
>
> excerpt from httpd.conf
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> .
> .
> RewriteEngine on
> .
> .
> .
>
> DocumentRoot /www
> ServerName webserver.mydomain.com
> ServerAlias sites.mydomain.com
> RewriteRule ^/([a-z0-9A-Z\.\-]+)(.*) /www/vhosts/$1/public_html/$2
>

> .
> .
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> comments appreciated.
>
> Dave
>
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
>



------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

RE: RewriteRule - works for /~user/ but not /user/

am 28.10.2003 19:51:39 von dave

>> have a domain name just for user personal sites.
>> mod_userdir makes "sites.mydomain.com/~username" work just fine.
>> user homedirs are in the /www/vhosts/username
>> mod_userdir correctly pushes ~user into the user public_html directory
>> UserDir public_html
>> /www/vhosts/username/public_html
>>
>> want to provide similar functionality to "sites.mydomain.com/username".
>
>See http://httpd.apache.org/docs-2.0/urlmapping.html#user .
>
>The purpose of the tilde (~) is to distinguish between a regular directory
>or file under the document root, and a user directory. You can't just
>remove the tilde and expect Apache to automatically know the differrence. I

this is understood... the subject line is misleading. the ~user isn't handled
by the rewrite rule, this is handled by mod_userdir and works as expected. I
was trying to impress what the desired end goal was, which was to force non
tilde requests into the same directory.

>see you attempted to compensate for this with a RewriteRule, but that
>rewrites the URI sent to the browser, not the filesystem path where files
>are read from (if I understand it correctly, still new to rewrite). You'll
>need to replace the tilde with something. The example shows the usage of an
>AliasMatch, which is keyed off of a /upages directory instead of a tilde.

requests to
http://sites.mydomain.com/ -> /www/

as per the document root directive in the virtual host.

I want to rewrite/redirect any requests to
http://sites.mydomain.com/user1 -> /www/vhosts/user1/public_html/
http://sites.mydomain.com/user2 -> /www/vhosts/user2/public_html/
http://sites.mydomain.com/user3 -> /www/vhosts/user3/public_html/


Dave



>> using the below RewriteRule ends up dumping me in the /www directory
>though
>> RewriteRule ^/([a-z0-9A-Z\.\-]+)(.*) /www/vhosts/$1/public_html/$2
>>
>> excerpt from httpd.conf
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> .
>> .
>> RewriteEngine on
>> .
>> .
>> .
>>
>> DocumentRoot /www
>> ServerName webserver.mydomain.com
>> ServerAlias sites.mydomain.com
>> RewriteRule ^/([a-z0-9A-Z\.\-]+)(.*) /www/vhosts/$1/public_html/$2
>>

>> .
>> .
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>
>> comments appreciated.
>>
>> Dave
>>
>>
>> ------------------------------------------------------------ ---------
>> The official User-To-User support forum of the Apache HTTP Server Project.
>> See for more info.
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> " from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>>
>
>
>
>----------------------------------------------------------- ----------
>The official User-To-User support forum of the Apache HTTP Server Project.
>See for more info.
>To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
>For additional commands, e-mail: users-help@httpd.apache.org
>
>



------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: RewriteRule - works for /~user/ but not /user/

am 28.10.2003 20:35:50 von Leif W

----- Original Message -----
From: "Dave [Hawk-Systems]"
To:
Sent: Tuesday, October 28, 2003 1:51 PM
Subject: RE: [users@httpd] RewriteRule - works for /~user/ but not /user/


> I want to rewrite/redirect any requests to
> http://sites.mydomain.com/user1 -> /www/vhosts/user1/public_html/
> http://sites.mydomain.com/user2 -> /www/vhosts/user2/public_html/
> http://sites.mydomain.com/user3 -> /www/vhosts/user3/public_html/

Again, modifying the example at
http://httpd.apache.org/docs-2.0/urlmapping.html#user ,

From:

AliasMatch ^/upages/([a-zA-Z0-9]+)/?(.*) /home/$1/public_html/$2

To:

AliasMatch ^/([a-zA-Z0-9]+)/?(.*) /www/vhosts/$1/public_html/$2


Would this work?


Leif



------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

RE: RewriteRule - works for /~user/ but not /user/

am 28.10.2003 20:40:49 von dave

>> I want to rewrite/redirect any requests to
>> http://sites.mydomain.com/user1 -> /www/vhosts/user1/public_html/
>> http://sites.mydomain.com/user2 -> /www/vhosts/user2/public_html/
>> http://sites.mydomain.com/user3 -> /www/vhosts/user3/public_html/
>
>Again, modifying the example at
>http://httpd.apache.org/docs-2.0/urlmapping.html#user ,
>
>From:
>
> AliasMatch ^/upages/([a-zA-Z0-9]+)/?(.*) /home/$1/public_html/$2
>
>To:
>
> AliasMatch ^/([a-zA-Z0-9]+)/?(.*) /www/vhosts/$1/public_html/$2

bingo! was too hung up on the "rewriterule" directive... forest for the trees
type of deal.

thanks

Dave



------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org