Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Adding multuple virtual hosts to apache server

Featured Replies

Hi,

 

I would like to ask you, how could I add multiple virtual hosts to my apache server.

 

I have edited the conf/extra/httpd-vhosts.conf file, and I have added the domain names to my hosts file in windows.

Oh I use vista.

My httpd-vhosts.conf file looks like this:

 

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot C:\xampp\xampp\htdocs
ServerName localhost

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

NameVirtualHost 127.0.0.1

<Directory "C:\xampp\xampp\testprojects  ">
 Order Deny,Allow
 Allow from all
</Directory>

<VirtualHost 127.0.0.1>
  DocumentRoot C:\xampp\xampp\testprojects\acm
  ServerName acm
</VirtualHost>

<VirtualHost 127.0.0.1>
  DocumentRoot C:\xampp\xampp\testprojects\komprador2010
  ServerName komprador2010
</VirtualHost>

 

What my problem is: I can see only the website that comes first. If I type the second in the browser, the first one comes.

eg.: now acm comes firts, When I type in acm.hu, it appears. Great! When I type in komprador2010.hu, acm appears.

 

When I change the order in the vhosts file, so that komprador comes firts, I will se only komprador even if I type in acm.

 

localhost works fine.

 

What can be wrong?

Hi,

 

I would like to ask you, how could I add multiple virtual hosts to my apache server.

 

I have edited the conf/extra/httpd-vhosts.conf file, and I have added the domain names to my hosts file in windows.

Oh I use vista.

My httpd-vhosts.conf file looks like this:

 

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot C:\xampp\xampp\htdocs
ServerName localhost

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

NameVirtualHost 127.0.0.1

<Directory "C:\xampp\xampp\testprojects  ">
 Order Deny,Allow
 Allow from all
</Directory>

<VirtualHost 127.0.0.1>
  DocumentRoot C:\xampp\xampp\testprojects\acm
  ServerName acm
</VirtualHost>

<VirtualHost 127.0.0.1>
  DocumentRoot C:\xampp\xampp\testprojects\komprador2010
  ServerName komprador2010
</VirtualHost>

 

What my problem is: I can see only the website that comes first. If I type the second in the browser, the first one comes.

eg.: now acm comes firts, When I type in acm.hu, it appears. Great! When I type in komprador2010.hu, acm appears.

 

When I change the order in the vhosts file, so that komprador comes firts, I will se only komprador even if I type in acm.

 

localhost works fine.

 

What can be wrong?

 

Your not setting the domain hostname, eg, domain.com or ServerName: www.domain.com

I don't know much about apache running on windows but try this...

 

NameVirtualHost *

<VirtualHost *:80>
       ServerAdmin webmaster@localhost
       DocumentRoot C:\xampp\xampp\htdocs
       ServerName localhost

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

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot C:\xampp\xampp\testprojects\acm
   ServerName acm

<Directory "C:\xampp\xampp\testprojects\acm">
	Options Indexes FollowSymLinks MultiViews
	AllowOverride All
	Order allow,deny
	allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot C:\xampp\xampp\testprojects\komprador2010
   ServerName komprador2010

<Directory "C:\xampp\xampp\testprojects\komprador2010">
	Options Indexes FollowSymLinks MultiViews
	AllowOverride All
	Order allow,deny
	allow from all
</Directory>
</VirtualHost>

  • Author

I don't know much about apache running on windows but try this...

 

NameVirtualHost *

<VirtualHost *:80>
       ServerAdmin webmaster@localhost
       DocumentRoot C:\xampp\xampp\htdocs
       ServerName localhost

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

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot C:\xampp\xampp\testprojects\acm
   ServerName acm

<Directory "C:\xampp\xampp\testprojects\acm">
	Options Indexes FollowSymLinks MultiViews
	AllowOverride All
	Order allow,deny
	allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot C:\xampp\xampp\testprojects\komprador2010
   ServerName komprador2010

<Directory "C:\xampp\xampp\testprojects\komprador2010">
	Options Indexes FollowSymLinks MultiViews
	AllowOverride All
	Order allow,deny
	allow from all
</Directory>
</VirtualHost>

Thanks Jock!

I have tried it, now my httpd-vhosts looks like this:

 

NameVirtualHost 127.0.0.1

<VirtualHost *:80>
       ServerAdmin webmaster@localhost
       DocumentRoot C:\xampp\xampp\htdocs
       ServerName localhost

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






<VirtualHost 127.0.0.1>
   ServerAdmin webmaster@localhost
   DocumentRoot C:\xampp\xampp\testprojects\komprador2010
   ServerName komprador2010

       <Directory "C:\xampp\xampp\testprojects\komprador2010">
               Options Indexes FollowSymLinks MultiViews
               AllowOverride All
               Order allow,deny
               allow from all
       </Directory>
</VirtualHost>

<VirtualHost 127.0.0.1>
   ServerAdmin webmaster@localhost
   DocumentRoot C:\xampp\xampp\testprojects\acm
   ServerName acm

       <Directory "C:\xampp\xampp\testprojects\acm">
               Options Indexes FollowSymLinks MultiViews
               AllowOverride All
               Order allow,deny
               allow from all
       </Directory>
</VirtualHost>

 

 

I have tried * as hostname, but it does not work. if I put <VirtualHost *:80> to the virtual hosts, then my 2 sites are redirected to komprador2010.hu/xampp and normal localhost appears. Is somethis wrong with my setting somewhere else?

  • Author

Thanks Jock!

I have tried it, now my httpd-vhosts looks like this:

 

NameVirtualHost 127.0.0.1

<VirtualHost *:80>
       ServerAdmin webmaster@localhost
       DocumentRoot C:\xampp\xampp\htdocs
       ServerName localhost

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






<VirtualHost 127.0.0.1>
   ServerAdmin webmaster@localhost
   DocumentRoot C:\xampp\xampp\testprojects\komprador2010
   ServerName komprador2010

       <Directory "C:\xampp\xampp\testprojects\komprador2010">
               Options Indexes FollowSymLinks MultiViews
               AllowOverride All
               Order allow,deny
               allow from all
       </Directory>
</VirtualHost>

<VirtualHost 127.0.0.1>
   ServerAdmin webmaster@localhost
   DocumentRoot C:\xampp\xampp\testprojects\acm
   ServerName acm

       <Directory "C:\xampp\xampp\testprojects\acm">
               Options Indexes FollowSymLinks MultiViews
               AllowOverride All
               Order allow,deny
               allow from all
       </Directory>
</VirtualHost>

 

 

I have tried * as hostname, but it does not work. if I put <VirtualHost *:80> to the virtual hosts, then my 2 sites are redirected to komprador2010.hu/xampp and normal localhost appears. Is somethis wrong with my setting somewhere else?

 

Ok, now I have added the 2 pieces of advice together! I have to put acm.hu and komprador2010.hu as serverName, as this is what I have set up after all!!! Thanks guys!! It works now!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.