Solved

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

Posted on 2004-03-29
8
1,070 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 50 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
2003 Server DNS/FS errors 6 49
Server 2008 to 2016 Essentials migration problem 6 39
ASA DHCP setup 5 28
Lightweight Networking 9 35
Data center, now-a-days, is referred as the home of all the advanced technologies. In-fact, most of the businesses are now establishing their entire organizational structure around the IT capabilities.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

786 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