Page 1 of 1

How to check why virtual hosts don't work

PostPosted: 11. May 2021 08:17
by fuzmic
Hi members

I have create a few virtual hosts before in my localhost using xampp for windows. There is no problem with these older entries.
As advised, to achieve this i place 1) entries in hosts of system32/drivers/etc eg 127.0.0.1 mysite.local 2) entries in httpd-vhosts.conf of c:\xampp\apache\conf\extra between <VirtualHost *:80> & </VirtualHost>.

But when i browse eg http://mysite.local (after restarting apache) it always end up in https://mysite.local/dashboard/

Question: how can i find out what went wrong. I have double check all entries, they are similar to what i have done before that work. Appreciate your pointers. :mrgreen:

Re: How to check why virtual hosts don't work

PostPosted: 11. May 2021 10:02
by Altrea
  • Define access and error log files for each specific vhost. If you request a vhost, you can check in the log entries if the vhost has matched / entries are added
    Code: Select all
        ErrorLog "logs/vhostname-error.log"
        CustomLog "logs/vhostname-access.log" common
  • Define
    Code: Select all
        LogLevel notice rewrite:trace5
    in each of your vhosts to also include rewrite messages in the log
  • xampp shell command
    Code: Select all
    httpd -S
    will output all defined and active vhosts

Re: How to check why virtual hosts don't work

PostPosted: 11. May 2021 10:26
by Nobbie
Did you activate include httpd-vhosts.conf in httpd.conf? Most people overlooked that it is commented out via # in first column.

Re: How to check why virtual hosts don't work

PostPosted: 13. May 2021 07:31
by fuzmic
Thanks guys for the response.

I found out why: it is because of the cache of the browser which already recognize mysite.local. Once the cache is cleared it works.