Forum Moderators: phranque

Message Too Old, No Replies

virtual host for only two sites in XAMPP

         

Anees

4:49 am on Jan 10, 2012 (gmt 0)

10+ Year Member



Hi

In my local machine i have 5 different projects stored in H:\xampp\htdocs

i have to set virtual host for first two domain
but i need to call the other in usual manner

ie. for my first two projects the urls will be
http ://project1.local
http ://project2.local

and the other projects am planning to call as
http ://localhost/project3
http ://localhost/project4
http ://localhost/project5

am able to set the multiple domains for first two folders
but when i call any folder from last three
it gives me an Object not found error

this is how i have set the virtual hosts

1) C:\Windows\System32\drivers\etc\hosts
#127.0.0.1 localhost
127.0.0.1 project1.local
127.0.0.1 project2.local

2) H:\xampp\apache\conf\extra
uncommnet NameVirtualHost *:80

3) <VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot H:/xampp/htdocs/project1
ServerName project1.local

<Directory "H:/xampp/htdocs/project1">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


4) <VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot H:/xampp/htdocs/project2
ServerName project2.local

<Directory "H:/xampp/htdocs/project2">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


so i need two virtual hosts to be working
as well as the other folders needs to call in normal way

please help me to solve this issue

Regards
Anees

penders

10:22 am on Jan 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



it gives me an Object not found error


What is the exact error? Are you using PHP? Are you attempting to reference the other folder by the full system path, or by the domain (localhost)?

#127.0.0.1 localhost


Why is this commented out?

Anees

12:41 pm on Jan 10, 2012 (gmt 0)

10+ Year Member



Hi

> #127.0.0.1 localhost
> Why is this commented out?

This was my mistake

Let me explain the issue here again

i have installed XAMPP and a stored number of projects in htdocs folder and i am calling those projects in browser as
http:// localhost/project1
http:// localhost/project2
http:// localhost/project3
http:// localhost/project4
http:// localhost/project5

and also
when i calls http:// localhost
it loads the home page of XAMPP

Now

i need to set Virtual host for my first 2 (or more but not for all) projects

so i wrote the above code in xampp\apache\conf\extra\httpd-vhosts.conf

and it works in the same way that i need
but the issue here is
after i set those when i calls http:// localhost it redirects to the home page of first virtual host that i set
http:// project1.local

and also
when i tried to to call the other projects other than the first two
for eg. http:// localhost/project3
its call actually goes like
http:// project1.local/project3
so the error
Object not found
fires..

Hope you understand the issue

Regards
Anees

Anees

6:47 am on Jan 11, 2012 (gmt 0)

10+ Year Member



Hi All

i have found the solution

made some corrections in the httpd-vhosts.conf file as below

<VirtualHost *>
DocumentRoot "H:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "H:/xampp/htdocs/project1"
ServerName project1.local
<Directory "H:/xampp/htdocs/project1">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot "H:/xampp/htdocs/project2"
ServerName project2.local
<Directory "H:/xampp/htdocs/project2">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


ie. removed this line
Options Indexes FollowSymLinks Includes ExecCGI

Could anyone please tell me whats that line do exactly

Regards
Anees

penders

11:36 am on Jan 11, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



ie. removed this line
Options Indexes FollowSymLinks Includes ExecCGI


I'm not sure why removing this line would resolve your problem? My gut feeling is that it was something else that resolved your problem. This overrides the default Options directive and permits directory listings (Indexes), allows symbolic links to be followed (FollowSymLinks), permits server-side-includes (Includes) and allows CGI scripts to be executed (ExecCGI) - but like I say, it overrides whatever might have been set as a default.

<VirtualHost *>  
DocumentRoot "H:\xampp\htdocs"
ServerName localhost
</VirtualHost>


You MUST use (forward) slashes as directory separaters, not backslashes, in the Apache conf files, even on Windows.

Anees

12:16 pm on Jan 11, 2012 (gmt 0)

10+ Year Member



Hi
Thank you for your reply

Yes i did change one more line on the top
earlier it was
NameVirtualHost *:80

and now
NameVirtualHost *

other than these i didn't make any changes on the previous code

penders

3:46 pm on Jan 11, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I think you would need "NameVirtualHost *" in order to match "<VirtualHost *>" in your new code, however *:80 should also have worked, unless you're not serving your content on port 80?