I want to bind two different domain in my VPS with the same ip and port, here is my httpd.conf:
<VirtualHost 106.187.96.123:80>
DocumentRoot /home/roy/sobuhu
ServerName aaa.com
</VirtualHost>
<VirtualHost 106.187.96.123:80>
DocumentRoot /disk1/allen/www
ServerName bbb.com
</VirtualHost>
<VirtualHost 106.187.96.123:80>
DocumentRoot /disk1/allen/www
ServerName www.bbb.com
</VirtualHost>
Can I config the ServerName use syntax like *.bbb.com ?
so I can access www.bbb.comăbbs.bbb.com with the DocumentRoot /disk1/allen/www.
Now I visit bbs.bbb.com, it will turn to /home/roy/sobuhu.
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /home/roy/sobuhu
ServerName aaa.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /disk1/allen/www
ServerName bbb.com
ServerAlias *.bbb.com
</VirtualHost>
Related
i got following code works fine
<VirtualHost *:80>
DocumentRoot /var/www/html/domain.com
ServerName www.domain.com
ServerAlias domain.com
</VirtualHost>
but when i put * and other in server i doesn't take to the file instead take me to root directory
this doesn't work
<VirtualHost *:80>
DocumentRoot /var/www/html/domain.com
ServerName other.domain.com
ServerAlias *.domain.com
</VirtualHost>
please help me with it
My web project need new mirrors domain each weeks.
The website is able to buy himself the domain with a Registar API.
I'm wundering if there is a way to automatically add the new domain to the virtualhost or config the virtualhost to redirect every domains not present in the virtualhost to a specific DocumentRoot ?
If I do that it will work ?
<VirtualHost *:80>
ServerName mirror.com
ServerAlias *.mirror.com
DocumentRoot /var/www/public
</VirtualHost>
<VirtualHost *:80>
ServerName *
DocumentRoot /var/www/public
</VirtualHost>
I fixed the issue with this :
<VirtualHost *:80>
ServerName mirror.com
ServerAlias *
DocumentRoot /var/www/public
</VirtualHost>
My vhost configuration at /etc/httpd/conf.d/vhost.conf looks like this:
NameVirtualHost *
<VirtualHost *>
ServerName www.example.com
DocumentRoot /var/www/html/site
</VirtualHost>
<VirtualHost *>
ServerName en.example.com
DocumentRoot /var/www/html/english
</VirtualHost>
<VirtualHost *>
ServerName photo.example.com
DocumentRoot /var/www/html/photo
</VirtualHost>
<VirtualHost *>
ServerName music.example.com
DocumentRoot /var/www/html/music
</VirtualHost>
<VirtualHost *>
ServerName video.example.com
DocumentRoot /var/www/html/video
</VirtualHost>
Now, only www.example.com is showing the correct site at /var/www/html/site. All other subdomains are giving a 500 internal server error. What am i doing wrong?
UPDATE:
i am really sorry guys... my Domain Name guy confirmed to me that my domain names were routed correctly to my IP address.... only after i did a dig en.example.com (something i should have done a lot earlier) did i realize that my Domain Name guys made a stupid misconfiguration... the web addresses were not even reaching my IP address to begin with... really sorry for the trouble folks :( :( - this vhost.conf file is all right
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /var/www/html/site
</VirtualHost>
<VirtualHost *:80>
ServerName en.example.com
DocumentRoot /var/www/html/english
</VirtualHost>
<VirtualHost *:80>
ServerName photo.example.com
DocumentRoot /var/www/html/photo
</VirtualHost>
<VirtualHost *:80>
ServerName music.example.com
DocumentRoot /var/www/html/music
</VirtualHost>
<VirtualHost *:80>
ServerName video.example.com
DocumentRoot /var/www/html/video
</VirtualHost>
I configure apache to the main domain in my server and it works just fine if just that domain:
in httpd.conf:
Listen maindomain.com:80
DocumentRoot "/home/webserver/maindomain/html"
but add a VirtualHost like this :
<VirtualHost secondoDomain.com>
DocumentRoot /home/webserver/secondoDomain/html/
ServerName secondoDomain.com
ErrorLog /home/webserver/secondoDomain/logs/error_log
CustomLog /home/webserver/secondoDomain/logs/access_log common
</VirtualHost>
all the calls to http://maindomain.com are been redirected to secondoDomain.com.
Any of you knows why?
When you add a virtual host, you need an entry for the main domain as well - as all hosts become virtual.
For example:
Listen *:80
<VirtualHost *:80>
ServerName maindomain.com
ServerAlias localhost
DocumentRoot "/home/webserver/maindomain/html"
</VirtualHost>
<VirtualHost *:80>
ServerName seconddomain.com
DocumentRoot "/home/webserver/secondoDomain/html/"
</VirtualHost>
Make sure you have a <Directory "/home/webserver/secondoDomain/html/"> for that second folder as well.
I have setup up 2 virtual hosts that share the same IP on a centos server running apache 2.
#<VirtualHost *:80>
# ServerAdmin webmaster#dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/a
ServerName www.a.com
ServerAlias a.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/b
ServerName www.b.com
ServerAlias b.com
</VirtualHost>
Regardless of what URL I point to. Site A shows up.
How can I fix? I should have a.com going to a and b.com going to b.
Thanks all
Is the following set in your httpd.conf?
NameVirtualHost *
An example from the documentation:
NameVirtualHost *
<VirtualHost *>
ServerName www.domain.tld
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>
make sure you have this directive as well
NameVirtualHost *
it could be displaying site A because it's set as the default document root. check your global settings, make sure the document root is not set to the same root as site A.
I have always declared the domain as the name.. never had issue.
NameVirtualHost localhost:80
<VirtualHost localhost:80>
DocumentRoot "/home/eddie/workspace/"
</VirtualHost>
<VirtualHost digbiz.localhost:80>
DocumentRoot "/home/eddie/workspace/Digital_Business/app/webroot"
</VirtualHost>
<VirtualHost wishlist.localhost:80>
DocumentRoot "/home/eddie/workspace/WishList/app/webroot"
</VirtualHost>
<VirtualHost phpmyadmin.localhost:80>
DocumentRoot "/srv/www/phpMyAdmin"
</VirtualHost>
<VirtualHost test.localhost:80>
DocumentRoot "/home/eddie/workspace/CakePHPTesting/app/webroot"
</VirtualHost>
<VirtualHost auth.localhost:80>
DocumentRoot "/home/eddie/workspace/EntMeetCapt/app/webroot"
</VirtualHost>