I am currently running one site which is accessible at http://localhost. I am now trying to set up Apache on my Windows machine so that I can have mutiple sites running off the localhost server. For example: http://localhost/site1 http://localhost/site2 http://localhost/site3 My development directory is C:/Users/Omzy/Documents/My Websites and this is what has been set as the DocumentRoot in httpd.conf Under this directory are the sub-directories for each site. I am using relative paths to address the files in my PHP scripts and I have an INCLUDE file called header.php with the following line: <link rel="stylesheet" type="text/css" href="/styles.css"/> Now when I browse to http://localhost/site1/index.php the stylesheet does not display. It did work before I set up the sub-directories (there were no sub-directories before). I know I have put in the forward slash at the beginning of the file name but that should not be the problem. I think I need to tell Apache that My Websites/site1 is the root for that site, and likewise for site2 and site3. Do I need to change something in httpd.conf? I tried setting virtualhosts too but that didn't work...
The best way is use virtual hosts. First add any hosts to your hosts file (probably c:\windows\systems32\drivers\etc\hosts - I use Linux so I'm not sure about this path), ie. 127.0.0.1 site1 127.0.0.1 site2 127.0.0.1 site3 And then define virtual hosts in your apache config. Another way is use relative path - styles.css instead of /styles.css
But how do I make it work so that I can access site1 by going to http://localhost/site1 rather than http://site1 If i use relative path styles.css this doesn't work for files in sub-directories of site1, e.g. My Websites/site1/advertising/
Some months ago I wrote an article on how to setup a windows multisite environment. Since I'm new, I can't post links but if you go to kobashicomputing.com look for the "How To Setup A Wamp environment article". That will answer your questoins.
Cheers kkobashi - I have that set that up now, but ideally I want to be able to access site1 by going to http://localhost/site1 rather than http://site1 - is this possible?