subdomains in directory

Using a single web hosting account to host multiple sites

subdomains in directory

Postby L8887 » Sat Sep 30, 2006 1:22 am

I use sunwave, and got subdomains like this:

subdomain1.mydomain.com
subdomain2.mydomain.com
... ...
subdomain99.mydomain.com



and now i need to make that my subdomain on server shoul be placed in domain direstories as subdirectories for each domain:

mydomain.com/subdomain1
mydomain.com/subdomain2
... ...


And from browser access must be seill subdomain1.mydomain.com (that redirect into mydomain.com/subdomain1)

I know that I have to made some changes in .htaccess file, and do something with MOD_REWRITE...

Any ideas ?

Thanks
L8887
 
Posts: 1
Joined: Sat Sep 30, 2006 1:14 am

Postby richardk » Sat Sep 30, 2006 8:37 am

There's a billion exmaples in this forum already.

In a .htaccess file in your document root:

For Apache 1.3:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST}     !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
RewriteRule ^(.*)$ /%1/$1 [QSA,L]


For Apache 2.x:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST}       !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST}   ^([^\.]+)\.domain\.com$ [NC]
RewriteCond %1:::%{REQUEST_URI} ^(.+):::/\1(/.*)?$ [NC]
RewriteRule ^(.*)$ /%1/$1 [QSA,L]


Replace "domain\.com" with your domain (no www). Escape any "." with a "\", eg "google.com" becomes "google\.com".
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 28 guests

cron