Apache virtualhosts problem?

  Gaz 25 07:46 24 Aug 04
Locked

Hya,

I have set-up apache but, I have an annoying problem with virtualhosts.

I set them up using:

VirtualHost *>

ServerName mywebsite.com

DocumentRoot /web/www

/VirtualHost>


VirtualHost *>

ServerName subdomain.mywebsite.com

DocumentRoot /web/www/subdomain

/VirtualHost>


Where subdomain and mywebsite is a variable.


However it always goes goes to the default directory with the default servername.

I have tried serveralias and uncommenting NameVirtualHost * to no avil.

Any ideas? Thanks in advance.

  Taran 13:48 24 Aug 04

Here's an example for you from one of my own server config files. I hope the format doesn't get too mangled in here, but you should be able to decipher it anyway:

#
# The * in the VirtualHost tag, tells apache that any request with site_name.com
# in the http header falls under this configuration.
# This is a far simpler way to configure virtual hosts on Apache, but it is not
# compatible with some old version browsers.
# Any browser that supports afterHttp 1.0 will be OK
#
<VirtualHost *>

#
# This should be self-explanatory; name and port under which the server
# identifies itself. If the port is 80 (default) it is not necessary to include it.
#
# If this is not set to a valid DNS name, server-side redirects will fail.
#
ServerName click here

#
# This address shows up on some server-generated pages, so make it a real one
#
ServerAdmin [email protected]_name.com

#
# Other names this server is known by.
#
ServerAlias site_name.com
ServerAlias sample_site.site_name.com

#
# Place where the documents for this domain live.
#
DocumentRoot /websites/site_name/webroot

#
# Directory specifications - check out the configuration file and the Apache
# documentation for full explanation.
#

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<Directory "/websites/site_name/webroot">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

#
# Index files - index.html or .htm or .php etc
#
DirectoryIndex index.html

#
# Access file - this is where your users can overwrite access for their
# directory (if you allow for them to overwrite, that is)
#
AccessFileName .htaccess


#
# Logging:
# Specify a separate location for this vritual host's logs.
#

#
# Hostname lookups: convenient but can slow down the server a bit
#
HostnameLookups Off
ErrorLog /websites/site_name/logs/error_log

#
# Leave LogLevel at warn or things will grind almost to a halt.
#
LogLevel warn

#
# These are the default apache log formats. If you want to log it
# differently then fiddle with this section.
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

#
# I like one info log - easier to read & parse.
#
CustomLog /websites/site_name/logs/access_log combined

#
# This adds a line containing server version and host name to server-generated pages.
# Optional, but not necessary
#
ServerSignature On

#
# CGI script location for my site_name site.
#
ScriptAlias /cgi-bin/ "/websites/site_name/cgi-bin/"

<Directory "/websites/site_name/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
#
# .cgi files are cgi scripts
#

AddHandler cgi-script .cgi

#
# This tells apache that files contained under pubhtml directory in users' home
# directories should be published under the site_name.com domain.
#

UserDir pubhtml

#
# This is the error handling part - customized error pages
#

<IfModule mod_negotiation.c>
<IfModule mod_include.c>
Alias /error/ "/websites/site_name/error/"

<Directory "/websites/site_name/error">
AllowOverride None
Options IncludesNoExec
AddHandler type-map var
Order allow,deny
Allow from all
LanguagePriority en es de fr
</Directory>
</IfModule>
</IfModule>


#
# The end.
#
</VirtualHost>

  Taran 13:51 24 Aug 04

The format got magled even more than I thought it might.

If you need a text file version of the above post to that effect and I'll upload one for you to look at.

T

  Gaz 25 14:30 24 Aug 04

I have managed to solve the problem. ;-)

I set a local address in the virtual hosts which was confusing it.

This thread is now locked and can not be replied to.

How to get Windows 10 for free | How to install Windows 10: There is still a way to avoid paying…

1995-2015: How technology has changed the world in 20 years

Alex Chinneck’s giant ice cube Christmas tree at Kings Cross

Apple rumours & predictions 2017: The iPhone 8, new iPads, and everything else you should expect fr7…