logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Virtual host not working properly? Need some help, please!
Author
fatandy



Joined: 22 Mar 2019
Posts: 3
Location: Romania, Bucharest

PostPosted: Fri 22 Mar '19 13:16    Post subject: Virtual host not working properly? Need some help, please! Reply with quote

Greetings.

I have been long running a small business Apache server and recently updated from Apache 1.3 to Apache 2.4. There was a learning curve with porting the configuration, but - i managed to get it working.

I am currently running Apache 2.4 on Windows x86.

One issue still persists :

in httpd.conf:

ServerName www.blah.com
DocumentRoot "c:/HTTP/blah.com"

The DocumentRoot is set to a default website - specific to the mother company. So good so far.

in httpd-vhosts.conf:
we have serve 4-5 domains, each with distinct content.

<VirtualHost *:80>
DocumentRoot "c:/HTTP/hello"
ServerName www.hello.com
ServerAlias *.hello.com
<Directory "c:/HTTP/hello">
Require all granted
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "c:/HTTP/goodbye"
ServerName www.goodbye.com
ServerAlias *.goodbye.com
<Directory "c:/HTTP/goodbye">
Require all granted
</Directory>
</VirtualHost>

all of them experience the same error.
when i type in the address goodbye.com instead of www.goodbye.com i get redirected to the www.blah.com website.
I i type www.goodbye.com i get the correct content.

I tried:

ServerName goodbye.com
ServerAlias *.goodbye.com

ServerName www.goodbye.com
ServerAlias goodbye.com

ServerName goodbye.com
ServerAlias www.goodbye.com

Nothing worked...
I'm surely missing something - as this is repeatable behaviour and totally predictable. Can someone please help me out ?
Back to top
fatandy



Joined: 22 Mar 2019
Posts: 3
Location: Romania, Bucharest

PostPosted: Fri 22 Mar '19 13:45    Post subject: Reply with quote

Update: After some more research, i discovered it redirects any www-less vhost not to the main documentroot, but to the first virtualhost website.

So, somehow, Apache does not recognise the www-less domain it is requested that...

DNS is set up correctly (i checked) - there is a www.goodbye.com (sample) specified in the DNS file.
Back to top
fatandy



Joined: 22 Mar 2019
Posts: 3
Location: Romania, Bucharest

PostPosted: Fri 22 Mar '19 14:20    Post subject: Reply with quote

Nevermind - i was the browser's cache Smile)

So, finally fixed after setting the vhost like this

ServerName www.hello.com
ServerAlias hello.com

Cleared the cache. Restarted the server. It now works. Presto!
Back to top


Reply to topic   Topic: Virtual host not working properly? Need some help, please! View previous topic :: View next topic
Post new topic   Forum Index -> Apache