logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in  RSS Apache Lounge  


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: Vhost :: Wrong webpage is showing up, why?
Author
skper12



Joined: 26 Jan 2020
Posts: 8
Location: Canada

PostPosted: Wed 29 Jan '20 9:03    Post subject: Vhost :: Wrong webpage is showing up, why? Reply with quote

Hi guys, I'm very new to Apache.

I have at least 4 domain names. 2 .com's and 2 .ca's.
Whenever I type at the URL sample4.ca, the other webpage will show up- the wrong page with www.sample1.com. But, when I type the whole address www.sample4.ca, it's the right webpage will show up.

I don't want the wrong webpages to show up whenever I type the right domain name/webpage.
Why is that? What did I do wrong in my config file?

Here's my httpd.conf file

<VirtualHost *:80>
DocumentRoot "C:/www/skper"
ServerName www.sample1.ca
ErrorLog logs/sample1.ca-error_log
CustomLog logs/sample1.ca-access_log common
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/www/epephotos"
ServerName www.sample2.com
ErrorLog logs/sample2.com-error_log
CustomLog logs/sample2.com-access_log common
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/www/jesr"
ServerName www.sample3.com
ErrorLog logs/sample3.com-error_log
CustomLog logs/sample3.com-access_log common
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/www/joypsychotherapy"
ServerName www.sample4.ca
ErrorLog logs/sample4.ca-error_log
CustomLog logs/sample4.ca-access_log common
</VirtualHost>

Confused
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 2807
Location: Hilversum, NL, EU

PostPosted: Wed 29 Jan '20 12:20    Post subject: Reply with quote

In every vhost try to add:

ServerAlias sample... (without the www)

Also you need a default/first vhost

Make this as the first:

Code:
<VirtualHost _default_:80>
Servername ..whatever..
DocumentRoot  a folder where you can place an error html  page..
ErrorLog ..whatever... or leave it out
CustomLog ..whatever.. ot leave it out
</VirtualHost>


That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first <VirtualHost>.
Back to top
skper12



Joined: 26 Jan 2020
Posts: 8
Location: Canada

PostPosted: Wed 29 Jan '20 18:08    Post subject: Reply with quote

Thank you so much Steffen for your help! Smile


I tried what you suggested, but it's still the same thing. I put the ServerAlias but it's still not showing up the right webpage.
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 2807
Location: Hilversum, NL, EU

PostPosted: Wed 29 Jan '20 18:16    Post subject: Reply with quote

Did you also added the First/Default host ?


Did you for example :

<VirtualHost *:80>
DocumentRoot "C:/www/skper"
ServerName www.sample1.ca
ServerAlias sample1.ca
ErrorLog logs/sample1.ca-error_log
CustomLog logs/sample1.ca-access_log common
</VirtualHost>

?
Back to top
skper12



Joined: 26 Jan 2020
Posts: 8
Location: Canada

PostPosted: Wed 29 Jan '20 18:31    Post subject: Reply with quote

Hi Steffen, so sorry I went back again to my config file and I just experimented, I think I solved my problem. I put ServerAlias *.sample4.ca that didn't work. Instead I deleted *. and just sample4.ca in my Serveralias and it worked! Very Happy

Thank you Steffen!
Back to top
skper12



Joined: 26 Jan 2020
Posts: 8
Location: Canada

PostPosted: Wed 29 Jan '20 18:36    Post subject: Reply with quote

Hi Steffen,

Yes I added the default first virtual host also.

here's my actual config: I took out the error logs directives

<VirtualHost *:80>
DocumentRoot "C:/www/skper"
ServerName www.skper.ca
ServerAlias skper.ca
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/www/epephotos"
ServerName www.epephotos.com
ServerAlias epephotos.com
</VirtualHost>


<VirtualHost *:80>
DocumentRoot "C:/www/jesr"
ServerName www.jesrearth.com
ServerAlias jesrearth.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/www/joypsychotherapy"
ServerName www.joypsychotherapy.ca
ServerAlias joypsychotherapy.ca
</VirtualHost>


Thanks again Steffen! Very Happy

I'm a newbie in Apache. Long way to go. Those websites are old when I first learned Apache 14yrs. ago due to competitive skills in the IT industry, I quit. Lately, I want to go back in this field. Thanks Steffen.
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 2807
Location: Hilversum, NL, EU

PostPosted: Wed 29 Jan '20 19:02    Post subject: Reply with quote

Good to hear that all works now.
Back to top


Reply to topic   Topic: Vhost :: Wrong webpage is showing up, why? View previous topic :: View next topic
Post new topic   Forum Index -> Apache