virtual hosts confusion
Posted by: dakta (---.216.159.143.dyn.plus.net)
Date: December 03, 2019 06:59PM

Hi, I'm new to WAMP and struggling a bit with virtual hosts.

I want a publically available server, with two websites and a cms installed on each, one being the main domain and the other being a subdomain.

The problem is I'm not sure how to set this up in the virtual server config, I have tried various ways and guides but always block access to one, or the other.

using the following config data:

<VirtualHost *:80>
DocumentRoot "c:/wamp64/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp64/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "c:/wamp64/www/daktadomain"
ServerName daktadomain.com
<Directory "c:/wamp64/www/daktadomain">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>


This allows me to connect to the admin console locally, and view the website properly on the internet from other computers, but if I try to add the subdomain as follows:

<VirtualHost *:80>
DocumentRoot "c:/wamp64/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp64/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "c:/wamp64/www/daktadomain"
ServerName daktadomain.com
<Directory "c:/wamp64/www/daktadomain">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "c:/wamp64/www/daktasubdomain"
ServerName subdomain.daktadomain.com
<Directory "c:/wamp64/www/daktasubdomain">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

The subdomain returns 403 forbidden, I appreciate I'm probably making a rookie mistake here but any ideas?

Options: ReplyQuote
Re: virtual hosts confusion
Posted by: Otomatic (Moderator)
Date: December 03, 2019 08:21PM

Hi,

This shows:
- That you wrote everything by hand, even modifying the original VirtualHost localhost that existed and that you should have been inspired by for your own VirtualHost.
- That you did not use the "Add a VirtualHost" tool integrated into Wampserver, because there are some small errors.

The original locahost VirtualHost was :
<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>

- The <Directory"......"> tag must include a final slash so:
<Directory "c:/wamp64/www/daktasubdomain/">
And so on for the other tags <Directory...

I myself use locally, a main site with three subdomains, but without the tld .com and it works very well.

However, in your case, I am concerned that the term "subdomain" in the ServerName may be misinterpreted.
In my case, the main ServerName is aviatechno and the ServerName of the subdomains are wampserver.aviatechno, faq-fra.aviatechno and le-pointu.aviatechno

- Add the final slash to the tags <Directory
- Replace subdomain by something else
- Add the line
Options +Indexes +Includes +FollowSymLinks +MultiViews
under the <Directory tags.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: virtual hosts confusion
Posted by: dakta (---.plus.com)
Date: December 03, 2019 09:24PM

My file is the way it was because I couldn;t modify the original to make things work, so I kept trying things until I ended up with the above.

Bottom line is - your advice has worked, so thank you very much I can de-stress a bit now! It's a long time since I've used this.

Options: ReplyQuote


Sorry, only registered users may post in this forum.