Link to home
Start Free TrialLog in
Avatar of ztot
ztot

asked on

Apache 1.3.29 vs IIS 5.1 (Virtual Host/Virtual Directory)

In IIS, http://localhost/ refer to the files in the path C:\Inetpub\wwwroot
However it is simple to create a virtual host/directory. For example http://localhost/VirtualHostName/ refer to d:\MyWebsite\Website

In Apache, C:\Program Files\Apache Group\Apache\htdocs (same like IIS C:\Inetpub\wwwroot)
But how to create a virtual host and access locally like what IIS does? E.g. http://localhost/VirtualHostName/ refer to d:\MyWebsite\Website
Avatar of chulsey
chulsey

The two technologies VirtualHost and Virtual Directory are quite different. IIS can do either or both of these. Apache on *nix can do this too, but it is not as easy. Just keep in mind that Virtual Hosting and a Virtual Directory are not interchangable terms and that there are some limitations when running Apache on Windows.

The Basics (Virtual Hosting)
There are three attributes required to define a web server, virtual or otherwise. These attributes are: IP Address, Listening Port, and ServerName (or HTTP1.1 header information). Every website, hosted on the same server, must have a unique combination of these attributes. No two websites hosted on the same server can have identical attributes to keep things working the way you would want.

I think you are actually asking how to do a Virtual Directory in Apache running on a Windows operating system. I don't know if this can be done using Apache on Windows. In *nix we can create a symbolic links, but I don't know how or if this can be done in Windows.

The closest solution I can think of is to change the default documents directory or "DocumentRoot" of your Apache installation. Look for a file named "httpd.conf". This file controls most of your Apache server configuration and is where you can define virtual hosts if you would like to do so. Using the information from your post, in this file you will see a declaration that looks something like this:

   DocumentRoot   C:\Program Files\Apache Group\Apache\htdocs

This line defines the default document directory for the default Apache web site.

OPTION #1 change the default document location
Modify the DocumentRoot line in httpd.conf to read as follows:

     DocumentRoot   d:\MyWebsite

Notice that I didn't include the trailing directory "Website" in this path. This is because you wanted the Apache installation to reference this site at "http://localhost/Website".

For additional information about virutal hosting with Apache check out
    http://httpd.apache.org/docs/vhosts/
        -- OR --
    http://httpd.apache.org/docs/
Avatar of ztot

ASKER

Thanks for ur comments, but this seem still can't solve my problem where i need it to refer to multiple folder. E.g. d:\MyWebsite\website and c:\Website2 and etc.

If the only way to make this is change the DocumentRoot then it will be very troublesome everytime b4 i view the files i need to chg the DocumentRoot. So any advance solution for this? Thanks.
ASKER CERTIFIED SOLUTION
Avatar of chulsey
chulsey

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ztot

ASKER

it still not working after i add in the line
Alias /wow "D:\WOW Vision\WOW Vision.web\Website 1.10"
and try to access via http://localhost/wow/
it display "The page cannot be found"

Pls advise. Thanks.
Did you restart the Apache service after making a change to the configuration file?
This is from the link I posted earlier about the Alias directive.

"Note that if you include a trailing / on the url-path then the server will require a trailing / in order to expand the alias. That is, if you use Alias /icons/ /usr/local/apache/icons/ then the url /icons will not be aliased."

This would also mean the opposite is true as well. Try leaving off the trailing slash in the URL therefor accessing this site at http://localhost/wow instead of http://localhost/wow/
Avatar of ztot

ASKER

I found out the error is due to the directory drive. It is work fine in c drive.

Alias /wow "C:\WOW Vision\WOW Vision.web\Website 1.10"
Work Fine

Alias /wow "D:\WOW Vision\WOW Vision.web\Website 1.10"
The page cannot be found
(I'm very sure i have put the files in the D:\WOW Vision\WOW Vision.web\Website 1.10)

Other problem (Alias /wow "C:\WOW Vision\WOW Vision.web\Website 1.10") is when i access page via http://localhost/wow it shown "You are not authorized to view this page" However i can access it via full url http://localhost/wow/index.htm
How to make it access via http://localhost/wow instead of using full url? and how to make it as directory browsing?

Thanks.
It seems that maybe you have not read any of the links I included in earlier posts. Please take the time to read the Apache 1.3 documentation at http://httpd.apache.org/docs/. Almost all of the information you are asking about can be found there.

If you have a specific question, please feel free to post it as a new question, but please at least take the time to read the links someone provides to you. You will likely find more than just the answer to your question and might discover other configuration options you might want to use. Who knows you might even find an answer that will help someone else out some day.

The answer:
1) You need to create a <Directory> entry in your httpd.conf file
http://httpd.apache.org/docs/mod/core.html#directory
2) Set the Options directive for the Directory directive defined in step #1
http://httpd.apache.org/docs/mod/core.html#options
3) Set the Indexes option for the Options directive defined in step #2

The whole thing looks something like this:
    <Directory /wow>
    Options Indexes
    </Directory>