Subdomain to directory

Using a single web hosting account to host multiple sites

Subdomain to directory

Postby jaycharles » Fri Mar 27, 2009 7:25 pm

I'm new to Apache, and I've been tasked with setting up wildcard subdomains to point to directories outside the document root.

DNS is being taken care of for each of the subdomains, so that part isn't a problem. What I need is a rewrite rule to point

anything.site.com

to

c:\somefolder\anything\public\files

I have access to httpd.conf if that makes a difference.

Any help would be most appreciated.
jaycharles
 
Posts: 2
Joined: Fri Mar 27, 2009 7:20 pm

Postby richardk » Sat Mar 28, 2009 8:34 am

mod_vhost_alias. Something along the lines of
Code: Select all
<VirtualHost *:80>
  ServerName example.com
  ServerAlias www.example.com

  DocumentRoot /main/document/root
</VirtualHost>

<VirtualHost *:80>
  ServerName wildcard.example.com
  ServerAlias *.example.com

  DocumentRoot c:\somefolder
  VirtualDocumentRoot c:\somefolder\%-3\public\files
</VirtualHost>


Also see FAQ: Virtual sub domains.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby jaycharles » Sat Mar 28, 2009 10:39 am

Thanks richardk... that's exactly what I needed.

One other problem I've run into... it turns out there are spaces and special characters in the path I need to work with (thanks, Adobe), and I'm having a really tough time getting the expression right.

anything.site.com

to

c:\Program Files\Adobe\Flash Media Server 3.5\conf\_defaultRoot_\anything.site.com\public\files

Thanks Again!
jaycharles
 
Posts: 2
Joined: Fri Mar 27, 2009 7:20 pm

Postby richardk » Sat Mar 28, 2009 6:28 pm

You should be able to put the path in "" to allow for spaces
Code: Select all
  VirtualDocumentRoot "c:\Program Files\Adobe\Flash Media Server 3.5\conf\_defaultRoot_\%0\public\files"
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

rewrite subdomain to directory ...

Postby luka8088 » Wed Jun 17, 2009 10:59 am

is this what you are looking for ?

blog.luka8088.com/2009/06/16/mod_rewrite/
luka8088
 
Posts: 1
Joined: Wed Jun 17, 2009 10:57 am
Location: Rijeka, Croatia, Europe


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 23 guests

cron