Author |
|
skper12
Joined: 26 Jan 2020 Posts: 10 Location: Canada
|
Posted: Wed 29 Jan '20 9:03 Post subject: Vhost :: Wrong webpage is showing up, why? |
|
|
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>
|
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Wed 29 Jan '20 12:20 Post subject: |
|
|
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: 10 Location: Canada
|
Posted: Wed 29 Jan '20 18:08 Post subject: |
|
|
Thank you so much Steffen for your help!
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: 3092 Location: Hilversum, NL, EU
|
Posted: Wed 29 Jan '20 18:16 Post subject: |
|
|
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: 10 Location: Canada
|
Posted: Wed 29 Jan '20 18:31 Post subject: |
|
|
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!
Thank you Steffen! |
|
Back to top |
|
skper12
Joined: 26 Jan 2020 Posts: 10 Location: Canada
|
Posted: Wed 29 Jan '20 18:36 Post subject: |
|
|
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/sample1"
ServerName www.sample1.ca
ServerAlias sample1.ca
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/www/sample2"
ServerName www.sample2.com
ServerAlias sample2.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/www/sample3"
ServerName www.sample3.com
ServerAlias sample3.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/www/sample4"
ServerName www.sample4.ca
ServerAlias sample4.ca
</VirtualHost>
Thanks again Steffen!
I'm a newbie in Apache. Long way to go. Those websites are old when I first learned Apache 14yrs. ago. Thanks Steffen.
Last edited by skper12 on Fri 14 Jan '22 5:23; edited 1 time in total |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Wed 29 Jan '20 19:02 Post subject: |
|
|
Good to hear that all works now. |
|
Back to top |
|