Mod_rewrite craziness with subdomains

Hey guys, hopefully one of the local experts can assist me with this issue.

I want to set my server up so that when a user goes to:
whatever.mydomain.com
They are taken to ->
mydomain.com/2/whatever
Which is located at /home3/public_html rather than /home/mydomain.com/public_html/whatever

I am doing this to be able to use another hard drive. Thus the /2/ (The site will have two)

Now I currently have the following code put in my site:

As it is currently written, this code takes my visitors from

http://whatever.mydomain.com to -> http://www.mydomain.com/whatever

Which is stored at /home/mydomain.com/public_html/whatever

I want it to take me to http://www.mydomain.com/2/whatever.
Located at /home3/public_html/whatever


#Get my My domain ready for subs
ServerAlias *.mydomain.com

#For my script to work I must have an alias that
#makes /2/whatever point to home3/public_html/whatever
Alias /2/ "/home3/public_html/"

<Directory "/home3/public_html/">
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

#Wild Subdomains
RewriteMap lowercase int:tolower
RewriteEngine on

RewriteCond ${lowercase:%{HTTP_HOST}} !^$
RewriteCond ${lowercase:%{HTTP_HOST}} !^www\.mydomain.com$

RewriteCond ${lowercase:%{HTTP_HOST}} ^([^.]+)\.mydomain\.com$
RewriteCond /home3/public_html/%1 -d

RewriteRule ^(.+) ${lowercase:%{HTTP_HOST}}/$1 [C]
RewriteRule ^([^.]+)\.mydomain\.com(.*) /$1$2 [L]


Now I have tried everything imaginable to change the code, adding /2/'s all over the place, and testing, but I cannot seem to get it to redirect properly.

Any suggestions? Thanks.

 

 

 

 

Top