Sub Domain - Have I tried everything?
Posted by: Bellatori (---.range86-131.btcentralplus.com)
Date: July 29, 2012 06:57PM

I must have read 40 or so different forums about how to set up subdomains. My setup works fine when there is only one domain involved but as soon as I try for two... nada

My host file looks like

HOSTS
127.0.0.1 localhost
127.0.0.1 www.bellatori.co.uk
127.0.0.1 bellator.co.uk
127.0.0.1 bellatori
127.0.0.1 dkk
127.0.0.1 dkk.bellatori.co.uk

I have bellatori.co.uk as a domain I own registered with FreeDNS.com and dkk.bellatori.co.uk is registered as a subdomain. My router successfully forwards the www.bellatori.co.uk to this computer which responds correctly when I have only the one domain and no subs.

My current httpd-vhosts.conf file contains

NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:\wamp\www"
</VirtualHost>

<VirtualHost *:80>
ServerName bellatori
ServerAlias bellatori.co.uk, www.bellatori.co.uk
DocumentRoot "C:\wamp\www\bellatori"
ErrorLog "C:\wamp\www\bellatori\logs\error.log"
CustomLog "C:\wamp\www\bellatori\logs\access.log" common
</VirtualHost>

<VirtualHost *:80>
ServerName dkk
ServerAlias dkk.bellatori.co.uk
DocumentRoot "C:\wamp\www\dkk"
ErrorLog "C:\wamp\www\dkk\logs\error.log"
CustomLog "C:\wamp\www\dkk\logs\access.log" common
</VirtualHost>

I have ticked the pache modules relating to virtual hosting and also removed the # from the httpd.conf file
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

I have tried at least a dozen versions of the two conf files but instead of two hosts I get either 403 or the directory structure from an internet call.

I really could do with some advice here.

Options: ReplyQuote
Re: Sub Domain - Have I tried everything?
Posted by: stevenmartin99 (Moderator)
Date: July 29, 2012 07:44PM

first of all , none of this should go in the httpd.conf

just unhash the include line and put the rest INTO the path of the include file.

Secondly , it will be 403 because you havent given permission..


you need to add the directory tags and a Require statement for who is allowed access

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Sub Domain - Have I tried everything?
Posted by: Bellatori (---.range86-131.btcentralplus.com)
Date: August 02, 2012 06:43PM

I have updated my httpd-vhosts.conf file to
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerName bellatori
ServerAlias bellatori.co.uk, www.bellatori.co.uk
DocumentRoot "C:\wamp\www\bellatori"
ErrorLog "C:\wamp\www\bellatori\logs\error.log"
<directory "C:\wamp\www\bellatori">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</directory>
</VirtualHost>

<VirtualHost *:80>
ServerName dkk
ServerAlias dkk.co.uk
DocumentRoot "C:\wamp\www\dkk"
ErrorLog "C:\wamp\www\dkk\logs\error.log"
<directory "C:\wamp\www\dkk">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</directory>
</VirtualHost>

I can see the bellatori domain but the dkk sub domain shows the bellatori domain as well...!?

Options: ReplyQuote
Re: Sub Domain - Have I tried everything?
Posted by: Bellatori (---.range86-131.btcentralplus.com)
Date: August 03, 2012 10:21AM

When I came back to my last post I noticed that I had made a mistake in the httpd-vhosts.conf file which I have no corrected.
ServerAlias dkk.co.uk --> dkk.bellatori.co.uk

I can see the bellatoriu web site but for the dkk one I just get the folder listing and no web site.

Options: ReplyQuote
Re: Sub Domain - Have I tried everything?
Posted by: RiggsFolly (---.as13285.net)
Date: August 03, 2012 10:37AM

With VHOST's if apache cannot find the domain used in the address it will default to the first vhost in the list.

In fact I think thats probably the only reason that the main site is working.



1.
## must be first VHOST so the the wamp menu page loads
## and because you dont really want the world to see it add a directory statement

<VirtualHost *:80>
DocumentRoot "D:/wamp/www"
ServerName localhost
ServerAlias localhost
<directory "C:/wamp/www/bellatori">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>


2. The MAIN site

<VirtualHost *:80>
ServerName www.bellatori.co.uk
ServerAlias bellatori.co.uk
DocumentRoot "C:/wamp/www/bellatori"
ErrorLog "C:/wamp/logs/bellatori_error.log"
<directory "C:/wamp/www/bellatori">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from all
</directory>
</VirtualHost>



3. The SUB DOMAIN ( which is normally a subfolder of the main sites DocumentRoot

<VirtualHost *:80>
ServerName dkk.bellatori.co.uk
DocumentRoot "C:/wamp/www/bellatori/dkk"
ErrorLog "C:/wamp/logs/dkk_error.log"
<directory "C:/wamp/www/bellatori/dkk">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from all
</directory>
</VirtualHost>


Note i changed the windows '\' to the unix '/'. Its normal to use the unix directory seperator in thes files and let apache do the "Oh I am running on windows so I will convert that"

Its better to have your log files in a folder that is not accessible by your site visitors so I changed that to the standard wamp log folder, unless you actually wanted users to see this.

The subdomain should be a subfolder of the main document root so i changed that.
Subdomains are normally addressed as subdomain.domain.co.uk or domain.co.uk/subdomain indicating their expected location as a subfolder.


These changes will allow you to access the site from t'internet, but unless your router has the correct loopback feature that spots that the ipaddress of a site you are addressing is in fact inside your own network you might also want to set up 2 more VHOSTS so you can use them internally.


## For internal network access
<VirtualHost *:80>
ServerName bellatori.localhost
DocumentRoot "C:/wamp/www/bellatori"
ErrorLog "C:/wamp/logs/bellatori_error.log"
<directory "C:/wamp/www/bellatori">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
# And any other pc's on your internal subnet
Allow from 192.168
</directory>
</VirtualHost>

<VirtualHost *:80>
ServerName dkk.bellatori.localhost
DocumentRoot "C:/wamp/www/bellatori/dkk"
ErrorLog "C:/wamp/logs/dkk_error.log"
<directory "C:/wamp/www/bellatori/dkk">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from all
</directory>
</VirtualHost>

Hope this helps

Options: ReplyQuote
Re: Sub Domain - Have I tried everything?
Posted by: Bellatori (---.range86-131.btcentralplus.com)
Date: August 03, 2012 04:11PM

Am painting this weekend...!? nut thanks for the reply. I will get back to you to let you know if I have got it working.
Regards
Jo

Options: ReplyQuote
Re: Sub Domain - Have I tried everything?
Posted by: Bellatori (---.range86-131.btcentralplus.com)
Date: August 03, 2012 05:41PM

OK so I am plying truant for 30 minutes. There is only so much paint brush cleaner that I can stand!!

The adjusted vhosts file is now (see end)... locally I get directory structures for localhost and dkk but the bellatori website for bellatori

So I have still got something wrong.

<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<directory "C:/wamp/www"> (also with /bellatori - no difference)
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>

<VirtualHost *:80>
ServerName www.bellatori.co.uk
ServerAlias bellatori.co.uk
DocumentRoot "C:/wamp/www/bellatori"
ErrorLog "C:/wamp/logs/bellatori_error.log"
<directory "C:/wamp/www/bellatori">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</directory>
</VirtualHost>

<VirtualHost *:80>
ServerName dkk.bellatori.co.uk
ServerAlias dkk
DocumentRoot "C:/wamp/www/bellatori/dkk"
ErrorLog "C:/wamp/logs/dkk_error.log"
<directory "C:/wamp/www/bellatori/dkk">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</directory>
</VirtualHost>

<VirtualHost *:80>
ServerName bellatori.localhost
DocumentRoot "C:/wamp/www/bellatori"
ErrorLog "C:/wamp/logs/bellatori_error.log"
<directory "C:/wamp/www/bellatori">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</directory>
</VirtualHost>

<VirtualHost *:80>
ServerName dkk.localhost
DocumentRoot "C:/wamp/www/bellatori/dkk"
ErrorLog "C:/wamp/logs/dkk_error.log"
<directory "C:/wamp/www/bellatori/dkk">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</directory>
</VirtualHost>

Options: ReplyQuote
Re: Sub Domain - Have I tried everything?
Posted by: stevenmartin99 (Moderator)
Date: August 03, 2012 08:07PM

this code seems to be completely wrong. you have the same code twice in some parts...

Servername is MOST important and they are not filled in correctly

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Sub Domain - Have I tried everything?
Posted by: Bellatori (---.range86-131.btcentralplus.com)
Date: August 03, 2012 10:10PM

OK now I am really puzzled. This is exactly what RiggsFolly posted.

You state *** Servername is MOST important and they are not filled in correctly ***

So what would be correct?

Thanks for your time...

Jo

Options: ReplyQuote
Re: Sub Domain - Have I tried everything?
Posted by: stevenmartin99 (Moderator)
Date: August 03, 2012 10:34PM

the servername needs to match the url and should have the .co.uk at the end
the alias is only if you wanted other names to match also

If these are real domains online.. im not sure why you are using the hosts file...
the hosts file is only to be used for domains for local use only , so i presume if you want to access locally you might want to just use dkk and bellatori

so i think your hosts file should be


HOSTS
127.0.0.1       localhost 
127.0.0.1	bellatori 
127.0.0.1	dkk

The vhosts file should be

NameVirtualHost *:80 

<VirtualHost *:80> 
      ServerName localhost 
      DocumentRoot "C:\wamp\www" 
</VirtualHost> 

<VirtualHost *:80> 
      ServerName dkk.bellatori.co.uk 
      ServerAlias dkk
      DocumentRoot "C:\wamp\www\dkk" 
      ErrorLog "C:\wamp\www\dkk\logs\error.log" 
      CustomLog "C:\wamp\www\dkk\logs\access.log" common 
</VirtualHost> 

<VirtualHost *:80> 
     ServerName bellatori.co.uk
     ServerAlias *.bellatori.co.uk bellatori
     DocumentRoot "C:\wamp\www\bellatori" 
     ErrorLog "C:\wamp\www\bellatori\logs\error.log" 
     CustomLog "C:\wamp\www\bellatori\logs\access.log" common 
</VirtualHost>

Make sure you put WampServer online (left click wamp> put online.

if you get 403 error then use the following code


NameVirtualHost *:80 

<VirtualHost *:80> 
      ServerName localhost 
      DocumentRoot "C:\wamp\www" 
</VirtualHost> 

<VirtualHost *:80> 
     ServerName dkk.bellatori.co.uk 
     ServerAlias dkk
     DocumentRoot "C:\wamp\www\dkk" 
     ErrorLog "C:\wamp\www\dkk\logs\error.log" 
     CustomLog "C:\wamp\www\dkk\logs\access.log" common 
     <directory "C:/wamp/www/dkk"> 
            Options Indexes FollowSymLinks 
            AllowOverride all 
            Order Deny,Allow 
            Allow from all 
      </directory> 
</VirtualHost> 

<VirtualHost *:80> 
      ServerName bellatori.co.uk
      ServerAlias *.bellatori.co.uk bellatori
      DocumentRoot "C:\wamp\www\bellatori" 
      ErrorLog "C:\wamp\www\bellatori\logs\error.log" 
      CustomLog "C:\wamp\www\bellatori\logs\access.log" common 
      <directory "C:/wamp/www/dkk"> 
            Options Indexes FollowSymLinks 
            AllowOverride all 
            Order Deny,Allow 
            Allow from all 
      </directory> 
</VirtualHost>
(the reason you may need this second section of code is because if wamp is OFFLINE. then all the sites and not just local sites wil be OFFLINE , so by adding these permissions you are telling apche that these sites should be accessible outside regardless of wamps ONLINE/OFFLINE setting)


So this setup will allow http: //dkk and http: //bellatori to work locally on your machine.

using dkk.bellatori.co.uk from outside will point to www/dkk
any other bellatori.co.uk request will point to www/bellatori

is this what you wanted to achieve?

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]



Edited 4 time(s). Last edit at 08/03/2012 11:51PM by stevenmartin99.

Options: ReplyQuote
Re: Sub Domain - Have I tried everything?
Posted by: Bellatori (---.range86-131.btcentralplus.com)
Date: August 03, 2012 11:46PM

Thanks once again.... I'll give it a go tomorrow morning and let you know how I get on.

I think light may be slowly dawning this end. The paint fumes don't help!

Options: ReplyQuote
Re: Sub Domain - Have I tried everything?
Posted by: Bellatori (---.range86-131.btcentralplus.com)
Date: August 04, 2012 10:18AM

Bummer...

I tried the first and got forbidden 403.

I then cut and pasted your second and got bellatori but once again dkk gives me 'Index of' and doesn't start the default.html

www.bellatori.co.uk works fine and
dkk.bellatori.co.uk/default.html delivers the required page. Its just the dkk.bellatori.co.uk returns the index and not the default page.. I bet I am missing something simple in what I have been told but it has got me stumped!

I changed the HOSTS file as suggested

127.0.0.1 localhost
127.0.0.1 bellatori
127.0.0.1 dkk

NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:\wamp\www"
</VirtualHost>

<VirtualHost *:80>
ServerName dkk.bellatori.co.uk
ServerAlias dkk
DocumentRoot "C:\wamp\www\dkk"
ErrorLog "C:\wamp\www\dkk\logs\error.log"
CustomLog "C:\wamp\www\dkk\logs\access.log" common
<directory "C:/wamp/www/dkk">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from all
</directory>
</VirtualHost>

<VirtualHost *:80>
ServerName bellatori.co.uk
ServerAlias *.bellatori.co.uk bellatori
DocumentRoot "C:\wamp\www\bellatori"
ErrorLog "C:\wamp\www\bellatori\logs\error.log"
CustomLog "C:\wamp\www\bellatori\logs\access.log" common
<directory "C:/wamp/www/bellatori">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from all
</directory>
</VirtualHost>



Edited 1 time(s). Last edit at 08/04/2012 10:26AM by Bellatori.

Options: ReplyQuote
Re: Sub Domain - Have I tried everything?
Posted by: stevenmartin99 (Moderator)
Date: August 04, 2012 11:27AM

Do u actually have a file called index.html or index.php in the folder??


Apache with wamp doesn't look for default.html

It only looks for index

Rename default to index


( of course you can add Default to the httpd.conf for apache to check for auto indexing )

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]



Edited 2 time(s). Last edit at 08/04/2012 11:34AM by stevenmartin99.

Options: ReplyQuote
Re: Sub Domain - Have I tried everything?
Posted by: Bellatori (---.range86-131.btcentralplus.com)
Date: August 04, 2012 01:18PM

Can all my troubles really be down to such a simple issue? Well apparently yes they can!!

Index.html it is.... and it is now all working. Many thanks...

How very irritating but we all have to learn somehow......

Warmest regards

Jo

Options: ReplyQuote


Sorry, only registered users may post in this forum.