Jump to content

Need help with VirtualDocumentRoot


kallin

Recommended Posts

After hours of unsuccessful attempts I'm out of ideas and I'm hoping someone here can help.

 

I would like to create VirtualDocumentRoots for my growing arsenal of sites.

I'm trying to get:

http://localhost/websiteA to have a document root of C:/www/websiteA

http://localhost/websiteB to have a document root of C:/www/websiteB

http://localhost/websiteC to have a document root of C:/www/websiteC

and etc...

 

I've tried dozens of different syntax combinations and nothing has worked.

Maybe someone here is more familiar with it than I am?

Link to comment
Share on other sites

The three sites you have are all on the same domain, hence, they all use the same DocumentRoot. You need to look up the documentation for vhosts and setup a different vhost for each site using a different hostname/domain.

 

At its simplest, you might have something like....

 

NameVirtualHost *

# This is the default host.
<VirtualHost *>
  DocumentRoot "/var/www/default"
</VirtualHost>

# Second site.
<VirtualHost site1>
  DocumentRoot "/var/www/site1"
</VirtualHost>

# Third site.
<VirtualHost site2>
  DocumentRoot "/var/www/site2"
</VirtualHost>

 

To get to these site you would use the addresses http://localhost http://site1 http://site2. You will also most likely need to edit your systems hosts file to ensure your browser does not attempt to resolve these host names via DNS.

Link to comment
Share on other sites

  • 3 weeks later...

I am a beginner but was wanting similar to what you want, I went for the following:

 

A wildcard DNS to catch all <app1>.server

 

then the following within vhosts of apache:

 

<VirtualHost *:80>

RewriteEngine On

 

ServerAlias *.server

ScriptAlias /cgi-bin "/usr/local/apache2.2.0a/cgi-bin"

RewriteRule ^/(.*) http://%{HTTP_HOST}:5081/$1 [proxy]

</VirtualHost>

 

VirtualHost *:5081>

CheckSpelling On

AddOutputFilterByType DEFLATE text/html text/plain text/xml

 

VirtualDocumentRoot /live/code/html/%1

Alias /common /live/code/html/%1

 

<Directory /live/code/html>

  Options Includes Indexes FollowSymLinks MultiViews

  AllowOverride None

  Order allow,deny

  Allow from all

</Directory>

 

therefore if you enter http://app1.server in your browser, the virtual document root will be /live/code/html/app1

 

It uses the 1st part of the servername as the subdir from /live/code/html

 

I redirect to port 5081 in this case, as I have other apps on other ports.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.