I have several unrelated sites. Two churches, a charity, a couple of family sites. Each site is not related and has different footers, and other included files.
Then you do need to use a VirtualHost for each of your sites.
Using a VirtualHost that has an individual DocumentRoot configured for each web site when implementing multiple web sites on the same server
C:\xampp\apache\conf\extra\httpd_vhost.conf
will do exactly what you want to do.
Advance Search the forum and the Internet for much help configuring VirtualHosts.
Is it possible for me to set a folder as document_root?
Yes, using a VirtualHost.
Is it possible to set the location of the include files?
Yeas, using a VirtualHost.
Will an image loaded with <img src="/image/balloons.png" width="100" height="185" alt="balloons"> work if the image file is located at
localhost/site1/image/balloons.png ?
No, as the server will be looking in
C:\xampp\htdocs\image\balloons.png
not in
C:\xampp\htdocs\site1\image\balloons.png.
See my first reply for the reason.
- Code: Select all
<img src="image/balloons.png"
...in the source of your files in the site1 folder will work when using site1 only - localhost/site1/image/balloons.png.
It will also work in your site1 folder on your hosted server in that same format.
Best advise is to use VirtualHosts in XAMPP which, if you could see your hosted web site's config files, would also more than likely be using VirtualHosts when hosting multiple domains (sites) for the same user and all taken care of by a backend server configuration script - depending on your Host.
In XAMPP with a correctly configured VirtualHost and Windows HOSTS file you could then have, for example:
http://mylocalchurch
http://mylocalchurch2
http://mylocalsite1
which do not require you to type in http://localhost/site1 etc. but the server name you specify, which is much more meaningful and less confusing and all hosted in XAMPP and pointing to your individual web site files correctly using an individual DocumentRoot, include and file location for each of your web sites, which also means no changing the paths from your hosted server site files for use in XAMPP, they should all work without changing anything...
...and BTW, using VirtualHost means you can locate your site files anywhere on your PC and not necessarily in the htdocs folder (
the server's default DocumentRoot) as you will be designating a DocumentRoot for each of your sites.