(www.)xxx.yyy.zzz -> /home/apache2/domains/othr/zzz/yyy/x

Using a single web hosting account to host multiple sites

(www.)xxx.yyy.zzz -> /home/apache2/domains/othr/zzz/yyy/x

Postby Cobi » Mon Mar 28, 2005 3:16 am

ok i need help making a rewrite rule to do this, but only if a virtualhost does not exist in the config file:
(www.)xxx.yyy.zzz/ to /home/apache2/domains/othr/zzz/yyy/x/xxx/htdocs
(www.)(aaa.)(bbb.)(...)xxx.yyy.zzz/cgi-bin to /home/apache2/domains/othr/zzz/yyy/x/xxx/sub/(bbb/)(aaa/)
and
(www.)xxx.yyy.zzz/cgi-bin to /home/apache2/domains/othr/zzz/yyy/x/xxx/cgi-bin

so...
http://test.winbots.org/index.html goes to /home/apache2/domains/othr/org/winbots/t/test/htdocs/index.html
and http://test.test.winbots.org/index.html goes to /home/apache2/domains/othr/org/winbots/t/test/sub/test/index.html
and http://test2.test1.test.winbots.org/index.html goes to /home/apache2/domains/othr/org/winbots/t/test/sub/test1/test2/index.html
and http://test.winbots.org/cgi-bin/index.cgi goes to /home/apache2/domains/othr/org/winbots/t/test/cgi-bin/index.cgi
and http://www.test.winbots.org/index.html goes to /home/apache2/domains/othr/org/winbots/t/test/htdocs/index.html
and... i think you get the picture ;)
but only do this if there isnt an existing virtual host in the config
Cobi
 

Re: (www.)xxx.yyy.zzz -> /home/apache2/domains/othr/zzz/y

Postby Guest » Mon Mar 28, 2005 3:18 am

*** EDIT ***
ok i need help making a rewrite rule to do this, but only if a virtualhost does not exist in the config file:
(www.)xxx.yyy.zzz/ to /home/apache2/domains/othr/zzz/yyy/x/xxx/htdocs
(www.)(aaa.)(bbb.)(...)xxx.yyy.zzz/ to /home/apache2/domains/othr/zzz/yyy/x/xxx/sub/(bbb/)(aaa/)
and
(www.)xxx.yyy.zzz/cgi-bin to /home/apache2/domains/othr/zzz/yyy/x/xxx/cgi-bin

so...
http://test.winbots.org/index.html goes to /home/apache2/domains/othr/org/winbots/t/test/htdocs/index.html
and http://test.test.winbots.org/index.html goes to /home/apache2/domains/othr/org/winbots/t/test/sub/test/index.html
and http://test2.test1.test.winbots.org/index.html goes to /home/apache2/domains/othr/org/winbots/t/test/sub/test1/test2/index.html
and http://test.winbots.org/cgi-bin/index.cgi goes to /home/apache2/domains/othr/org/winbots/t/test/cgi-bin/index.cgi
and http://www.test.winbots.org/index.html goes to /home/apache2/domains/othr/org/winbots/t/test/htdocs/index.html
and... i think you get the picture ;)
but only do this if there isnt an existing virtual host in the config

p.s. i couldnt edit the other one so i posted it as a reply
Guest
 

Postby Caterham » Mon Mar 28, 2005 6:17 am

are you using name based virtualhosts or IP based virtual hosts?
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Cobi » Mon Mar 28, 2005 7:50 am

Name Based
Cobi
 

Postby Caterham » Mon Mar 28, 2005 10:47 am

For name based virtual hosting, the first virtualhost is the default one.
http://httpd.apache.org/docs-2.0/en/vhosts/name-based.html wrote:As a consequence, the first listed virtual host is the default virtual host.


So you have to place the rule there.

Code: Select all
RewriteEngine On
RewriteMap    lowercase    int:tolower
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9_-]+)\.([a-z0-9_-]+)\.([a-z]{2,6})(:[0-9]{2,4})?$ [NC]
RewriteRule ^/(.*) /home/apache2/domains/othr/${lowercase:%4}/${lowercase:%3}/t/${lowercase:%2}/htdocs/$1 [L]
I hope this might help you to develop other rules.
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Cobi » Mon Mar 28, 2005 6:57 pm

well, with test.winbots.org it worked fine, but with abc.winbots.org it didnt work... it gave me a 404... i put the abc stuff in /home/apache2/domains/othr/org/winbots/a/abc/htdocs..
(what about the two other rules i wanted? the sub1.sub2.sub3.subx.test.winbots.org to /home/apache2/domains/othr/org/winbots/t/test/sub/subx/sub3/sub2/sub1/?)
Cobi
 

Postby Caterham » Wed Mar 30, 2005 4:14 am

[quote="Caterham]I hope this might help you to develop other rules.[/quote]This is just an example how thinks can go... take also a look on RewriteMaps or other directives / modules, such as mod_vhost_alias.

I won't develop complete complex practical rules "just for fun"...

http://www.scriptlance.com
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Kocpag » Wed Aug 16, 2006 10:52 am

Great information
Kocpag
 
Posts: 1
Joined: Wed Aug 16, 2006 10:32 am
Location: USA


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 40 guests

cron