Strrange Behavior Of VirtualHosts In Apache (CentOS6)

Home » CentOS » Strrange Behavior Of VirtualHosts In Apache (CentOS6)
CentOS 2 Comments

Hello,

there is a short explanation about virtual hosts in Apache … https://wiki.CentOS.org/TipsAndTricks/ApacheVhostDefault

the `hostname` gives a different donmain name than what should be hosted … e.g. `hostname` is host.example.org and the domain to be hosted is example.com, so I did this:


ServerName host.example.org DocumentRoot /var/www/default

# used to get let’s encrypt for the mail server

ServerName mail.example.org ServerAlias SMTP.example.org DocumentRoot /var/www/mail


ServerName www.example.com DocumentRoot /var/www/domain


ServerAlias *.example.com DocumentRoot /var/www/catchall

the DocumentRoot directories are empty, only in /var/www/default I have a PHP script: host.php

now the strange behavior;

http://mail.example.org/ <-- works http://smtp.example.org/ <-- doen't work http://smtp.example.org/host.php <-- gives the HTTP_HOST (PHP-script), but why? http://www.example.com/ <-- works http://hello.example.com/ <-- doesn't work http://hello.example.com/host.php <-- gives the HTTP_HOST (PHP-script), but why? doesn’t work does mean, that access/errors are logged in logfile of wrong virtual host … where is my mistake; Thanks, Walter

2 thoughts on - Strrange Behavior Of VirtualHosts In Apache (CentOS6)

  • yes not really, the strange thing was something different;

    httpd -S lists all vhosts, and at last
    ‘Syntax OK’

    and exact this was the strange; I’m used to add the port number to ServerAlias and this was the mistake … httpd -S, didn’t realize this

    I removed the port numbers from ServerAlias entries and now it works :-)

    Greetings, Walter