Please help.
I'm new with mod_rewrite and am hoping that someone can help me out.
The problem is to support the following for our users:
http://www.domain.com/~user
http://www.domain.com/user
user.domain.com
I'm almost there, with only the case where a user has their own .htaccess file (in a subdirectory) AND they are using the user.domain.com form from above failing
The user.domain.com/protected-dir is rewritten as http://www.domain.com/protected-dir (which dosen't exist) instead of user.domain.com/protected-dir or http://www.domain.com/user/protected-dir.
Any suggestions for cleaning up the cgiwrap rewrites would also be greatly appreciated.
The details are below:
Id: 'user' has home directory /users/user/
All web pages are in public_html under the home directory.
httpd.conf:
...
Alias /users/ "/users/"
...
RewriteMap non-tilde-user prg:/usr/local/apache/bin/rewrite_script.pl
#
RewriteMap lowercase int:tolower
#
RewriteCond ${lowercase:%{HTTP_HOST}} !^$
RewriteCond ${lowercase:%{HTTP_HOST}} !^www.domain.com$
RewriteCond ${lowercase:%{HTTP_HOST}} ^(www.)?([^.]+).domain.com$
RewriteRule ^(.+) ${lowercase:%{HTTP_HOST}}$1 [C]
RewriteRule ^(www.)?([^.]+).domain.com(.*) /users/$2/public_html/$3
#
RewriteRule ^/([^~/]+)/cgi-bin/(.*) /cgi-bin/$2 [PT]
RewriteRule ^/([^~/]+)/cgi-local/(.*) /cgi-bin/cgiwrap/$1/$2 [PT]
RewriteRule ^/([^~/]+)/cgi-local-d/(.*) /cgi-bin/cgiwrapd/$1/$2 [PT]
#
RewriteRule ^/([^~/]+)(/?.*) ${non-tilde-user:$1|nouser}$2
#
RewriteRule ^/~([^/]+)/cgi-bin/(.*) /cgi-bin/$2 [PT]
RewriteRule ^/~([^/]+)/cgi-local/(.*) /cgi-bin/cgiwrap/$1/$2 [PT]
RewriteRule ^/~([^/]+)/cgi-local-d/(.*) /cgi-bin/cgiwrapd/$1/$2 [PT]
#
/usr/local/apache/bin/rewrite_script.pl:
#!/usr/bin/perl
$| = 1;
while (<STDIN>) {
s/n//g;
if (($name,$passwd,$uid,$gid,$quota,$comment,$geos,$dir,$shell) = getpwnam($_)
) {
print "/users/$name/public_htmln";
} else {
print "/$_n";
}
}