Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-03-29
8
Medium Priority
?
1,089 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:ztot
  • 5
  • 3
8 Comments
 

Expert Comment

by:chulsey
ID: 10716882
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/
0
 

Author Comment

by:ztot
ID: 10722140
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.
0
 

Accepted Solution

by:
chulsey earned 200 total points
ID: 10723540
Sorry for the confusion, I don't think I interpreted your question the way you intended. The virtual directory equivalent directive in Apache is called "Alias".

So again in the httpd.conf file look for the section that defines a sample Alias directive. Using the example from your followup post the entry would look like:

Syntax of the Alias directive: Alias <virtual_dir> <physical_path>
So for this case the actual Alias line would read:

Alias /website D:\MyWebsite\website
Alias /website2 C:\website2

For more information about the Alias directive look at: http://httpd.apache.org/docs/mod/mod_alias.html#alias
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ztot
ID: 10723964
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.
0
 

Expert Comment

by:chulsey
ID: 10724653
Did you restart the Apache service after making a change to the configuration file?
0
 

Expert Comment

by:chulsey
ID: 10724798
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/
0
 

Author Comment

by:ztot
ID: 10733174
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.
0
 

Expert Comment

by:chulsey
ID: 10736281
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>
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

WARNING:   If you follow the instructions here, you will wipe out your VTP and VLAN configurations.  Make sure you have backed up your switch!!! I recently had some issues with a few low-end Cisco routers (RV325) and I opened a case with Cisco TA…
This article explains the fundamentals of industrial networking which ultimately is the backbone network which is providing communications for process devices like robots and other not so interesting stuff.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question