3

I have Apache 2.2 installed on Windows, the folder that serves all my websites is:

C:\Users\GSTAR\Documents\Web Sites

Within this folder there are subfolders for each website

I currently access these websites on my server by navigating to http://localhost/site1, http://localhost/site2, etc.

The problem I have now is that some of the websites have relative URL paths, and this causes problems as resources are not found (it tries to look in the root folder).

I don't particularly wish to use absolute URLs. I had a look into vhosts, as this might be a solution. But I am having some trouble with this.

I wish to continue using the same URLs for accessing the websites - however some of the tutorials I have read suggest to use a site.local type convention, but I would prefer not to.

Anybody got any suggestions how to make this work?

3 Answers 3

1

The ideal way of dealing with this is to create multiple vhosts - one for each site. It might be worthwhile to take a one time penalty of changing URLs and changing the way you're used to accessing them. This will definitely save you a lot of time & trouble if you continue using this setup for multiple projects. This looks like a development setup, so it'd also help mimic production behavior.

1

I am with skjaidev in that matter. The best and easiest way for you, should be to setup vhosts. Which is fairly simple. All you need to do is:

1.) Deactivate the ServerRoot and DocumentRoot directives in the httpd.conf (or apache.conf, or however the master configuration file is called on your system). Deactivate means either delete the line, or preferably put a '#' infront of it.

2.) Deactivate the corresponding <Directive...> container. You can find them as they have the same path as your DocumentRoot.

Those two steps are not required, but i do it this way for some reasons

3.) Include a new file called vhost.conf or use the one offered by your installation. You can achieve this by adding the following line in your httpd.conf

Include "C:\Path\to\apache2\confdir\vhost.conf"

4.) Add NameVirtualHost *:80 on top of the vhost.conf (exactly one time) with 80 being the port you want the apache to listen to

5.) Add a <VirtualHost ...> container like this.

<VirtualHost *:80>
   ServerName site1.local
   DocumentRoot "C:\Users\GSTAR\Documents\Web Sites\Site1\"
   DirectoryIndex index.html index.php 
   <Directory />
      Options FollowSymLinks
      AllowOverride None
   </Directory>

   <Directory "C:\Users\GSTAR\Documents\Web Sites\Site1\">
      Options Indexes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
   </Directory>
</VirtualHost>

This is just an example configuration. You have to adjust this to fit your needs.

6.) Add as many <VirtualHost ...> containers in above's style as you want. Just adjust the DocumentRoot and Directory directives

7.) To make the site1.local and site2.local work you will have to either edit your hosts file, or modify your local DNS server. In case you are using Windows 7, you can access this file by right clicking your preferred editor and start it with administrator rights. If you don't, you can't edit it. Now you open it by browsing to C:\Windows\system32\drivers\etc\hosts

If you need further assistance just leave a comment.

0

You're probably looking for something like mod_rewrite http://httpd.apache.org/docs/current/mod/mod_rewrite.html with RewriteBase.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .