subdomains

#1
Hello,
so far ive been setting up different vhosts for different subdomains. In near future, i will have to create 100+ small pages in one domain but on different subdomains. Here is my question. Is this possible to create one vhost to handle these subdomains? The rule should be:
domain.com : /home/domain/www/
sub1.domain.com /home/domain/www/sub1/
sub2.domain.com /home/domain/www/sub2/

Regards
Xinn
 
#3
Simple rules means a lot of work for me ;)
I tried some configurations mentioned on this site... But they dont work for me..

This one would be ideal for me:

RewriteEngine on

RewriteMap lowercase int:tolower

# allow CGIs to work
RewriteCond %{REQUEST_URI} !^/cgi-bin/

# check the hostname is right so that the RewriteRule works
RewriteCond ${lowercase:%{SERVER_NAME}} ^www\.[a-z-]+\.domain\.pl$

# concatenate the virtual host name onto the start of the URI
# the [C] means do the next rewrite on the result of this one
RewriteRule ^(.+) ${lowercase:%{SERVER_NAME}}$1 [C]

# now create the real file name
RewriteRule ^www\.([a-z-]+)\.domain\.pl/(.*) /home/domain/public_html/$1
Any ideas how to force it to work? ;)
 

mistwang

LiteSpeed Staff
#4
There is a bug in rewritemap will be fixed in next release, but you don't need to use the lowercase map, as the %{SERVER_NAME} has been converted to lowercase by LSWS already, so you can try:

Code:
RewriteCond %{SERVER_NAME} !^www\.us\.pl$
RewriteCond %{SERVER_NAME} ^(.*)\.us\.pl$
RewriteRule ^/(.*)$  /home/uspl/public_html/%1/$1
Set "Rewrite Log level" to "9" and check the error log to debug those rules.
[/code]
 
#5
Hello,

thank you for your answer Goerge,

the rules which you wrote almost fits my needs, there is just small *bug*,
when you access www.sub.domain.pl it searchs for files in:
/home/user/public_html/www.sub not in /home/user/public_html/sub

This rule works perfect ( maybe someone other will use it in future - this is why i post it here ):

RewriteCond %{SERVER_NAME} !^www\.domain\.pl$
RewriteCond %{SERVER_NAME} ^(www\.)?([a-z-]+)\.domain\.pl$
RewriteRule ^/(.*)$ /home/domainpl/public_html/%2/$1
Thank you for your help Mistwang,

Best Regards
xinn
 
Top