www.test.com -> domains/t/e/test.com

Using a single web hosting account to host multiple sites

www.test.com -> domains/t/e/test.com

Postby areidmtm » Sun Mar 16, 2008 3:18 pm

I found something like this:
Code: Select all
RewriteCond %{HTTP_HOST} ^((www|local|dev|stage)\.)?(([^\.])([^\.])[^\.]+)\.(com|net|org|info|biz)
RewriteCond %{DOCUMENT_ROOT}/domains/%4/%5/%3.%6/$1 -f
RewriteRule ^(.*)$ /domains/%4/%5/%3.%6/$1 [L]


But it doesn't seem to work. I also don't need the local|dev|stage, just the www
areidmtm
 
Posts: 20
Joined: Thu Aug 24, 2006 10:43 am

Postby richardk » Sun Mar 16, 2008 3:51 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.((.)(.).+)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^((.)(.).+)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%2/%3/%1%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^www\.((.)(.).+)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^((.)(.).+)$ [NC]
RewriteRule ^(.*)$ /%2/%3/%1/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby areidmtm » Sun Mar 16, 2008 4:14 pm

Perfecto! Thank you!
areidmtm
 
Posts: 20
Joined: Thu Aug 24, 2006 10:43 am

Postby areidmtm » Sun Mar 16, 2008 6:40 pm

I have another question. I am using the code posted above with a few modifications to the directory structure, as follows:

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.((.)(.).+)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^((.)(.).+)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/domains/%2/%3/%1%{REQUEST_URI}/public_html/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^www\.((.)(.).+)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^((.)(.).+)$ [NC]
RewriteRule ^(.*)$ /domains/%2/%3/%1/public_html/$1 [QSA,L]


Now what I'd like to do is split out the sub-domain, if any.

If the domain is mydomain.com or www.mydomain.com then use this directory: /domains/m/y/mydomain.com/public_html/

If there is a sub-domain other then www, such as test.mydomain.com then use this directory: /domains/m/y/mydomain.com/sub_domains/test/

Any help much appreciated!
areidmtm
 
Posts: 20
Joined: Thu Aug 24, 2006 10:43 am

Postby richardk » Mon Mar 17, 2008 2:52 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond /public_html%{HTTP_HOST} ^(/public_html)www\.(([^\.]+)([^\.]+)[^\.]*\.(com|net|org|info|biz))$ [NC,OR]
RewriteCond /sub_domains/%{HTTP_HOST} ^(.+)\.(([^\.]+)([^\.]+)[^\.]*\.(com|net|org|info|biz))$ [NC,OR]
RewriteCond /public_html%{HTTP_HOST} ^(/public_html)(([^\.]+)([^\.]+)[^\.]*\.(com|net|org|info|biz))$ [NC]
RewriteCond %{DOCUMENT_ROOT}/domains/%3/%4/%2%1%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond /public_html%{HTTP_HOST} ^(/public_html)www\.(([^\.]+)([^\.]+)[^\.]*\.(com|net|org|info|biz))$ [NC,OR]
RewriteCond /sub_domains/%{HTTP_HOST} ^(.+)\.(([^\.]+)([^\.]+)[^\.]*\.(com|net|org|info|biz))$ [NC,OR]
RewriteCond /public_html%{HTTP_HOST} ^(/public_html)(([^\.]+)([^\.]+)[^\.]*\.(com|net|org|info|biz))$ [NC]
RewriteRule ^(.*)$ /domains/%3/%4/%2%1/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby areidmtm » Mon Mar 17, 2008 6:39 pm

Thanks!

but it doesn't seem to work.

if the domain is test.com it goes to: /domains/tes/t/test.com/public_html/

Thanks for you help!
areidmtm
 
Posts: 20
Joined: Thu Aug 24, 2006 10:43 am

Postby richardk » Tue Mar 18, 2008 3:48 pm

I think this should fix it
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond /public_html%{HTTP_HOST} ^(/public_html)www\.(([^\.])([^\.])[^\.]*\.(com|net|org|info|biz))$ [NC,OR]
RewriteCond /sub_domains/%{HTTP_HOST} ^(.+)\.(([^\.])([^\.])[^\.]*\.(com|net|org|info|biz))$ [NC,OR]
RewriteCond /public_html%{HTTP_HOST} ^(/public_html)(([^\.])([^\.])[^\.]*\.(com|net|org|info|biz))$ [NC]
RewriteCond %{DOCUMENT_ROOT}/domains/%3/%4/%2%1%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond /public_html%{HTTP_HOST} ^(/public_html)www\.(([^\.])([^\.])[^\.]*\.(com|net|org|info|biz))$ [NC,OR]
RewriteCond /sub_domains/%{HTTP_HOST} ^(.+)\.(([^\.])([^\.])[^\.]*\.(com|net|org|info|biz))$ [NC,OR]
RewriteCond /public_html%{HTTP_HOST} ^(/public_html)(([^\.])([^\.])[^\.]*\.(com|net|org|info|biz))$ [NC]
RewriteRule ^(.*)$ /domains/%3/%4/%2%1/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby areidmtm » Wed Mar 19, 2008 11:19 am

That was it! Thanks so much for you help!
areidmtm
 
Posts: 20
Joined: Thu Aug 24, 2006 10:43 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 18 guests

cron