How i can correctly direct multiple url in a same conf file.let me know if i am correct to put my conf file like this
<VirtualHost *:80>
ServerName domain1.com
ServerAlias domain2.com
... real vhost settings ...
</VirtualHost>
and what if user could'nt find the url then he should me directed to a default page.please if anyone can tell me how i can put a redirection to a defult only if that url is not found.
You can set up apache vhosts like this:
<VirtualHost *:80>
ServerName domain1.com
ServerAlias *.domain1.com
ServerAlias domain2.com
ErrorDocument 404 /errors/error404.php
#... real vhost settings ...
</VirtualHost>
Any not found URL will be redirected to /errors/error404.php, or any URL you give here.
Ref http://en.wikipedia.org/wiki/HTTP_404.
For ServerAlias domain2.com, you must set up first a bind primary zone for this domain in your name server, this cname will point to your server's IP, otherwise, this line will have no effect.
Related
I'm running Apache2 on Debian Jessie, when i try to enter my site without www. it returns a 404 page.
What i have in apache config:
<VirtualHost *:80>
DocumentRoot "/var/www/sites/example.com"
ServerName www.example.com
ServerAlias example.com
</VirtualHost>
<VirtualHost *:443>
SSLEngine On
DocumentRoot "/var/www/sites/example.com"
ServerName www.example.com
ServerAlias example.com
SSLCertificateFile /etc/chain.pem
SSLCertificateKeyFile /etc/key.pem
</VirtualHost>`
Now , there are no other definitions in "sites-enabled" that mentions the site
1- Both example.com and www.example.com have the same ip ( Not a DNS problem )
2- There are no extra configurations in "sites-available"
3- https://example.com works fine but http://example.com returns a 404
There was a <VirtualHost *:80> that has no ServerName , and apache used default server hostname which was example.com
I am not able to setup subdomain through virtual host in my ubuntu server. Followed following steps
in /etc/hosts
127.0.0.1 localhost
10.0.0.1 domain.com
10.0.0.1 sub.domain.com
in /etc/apache2/sites-available/ i created two files domain.com and sub.domain.com
in domain.com file,
<VirtualHost *:80>
ServerAdmin webmaster#domain.com
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com/
ErrorLog /var/www/domain.com/logs/error.log
CustomLog /var/www/domain.com/logs/access.log combined (all these folders exists)
</VirtualHost>
in sub.domain.com file,
<VirtualHost *:80>
ServerAdmin webmaster#sub.domain.com
ServerName sub.domain.com
ServerAlias www.sub.domain.com
DocumentRoot /var/www/sub.domain.com/
ErrorLog /var/www/sub.domain.com/logs/error.log
CustomLog /var/www/sub.domain.com/logs/access.log combined (all these folders exists)
</VirtualHost>
After this is i enabled the site by a2ensite domain.com, a2ensite sub.domain.com and then restarted apache server.
Domain.com works fine. But sub.domain.com is not working. I am getting error "Webpage not available".
Can anyone tell me what is the mistake i am doing??
Can anybody help me in creating subdoain through webmin. I want to create subdomain like test.xxxxx.com for this I tried with several reference site but no luck.
exp.
http://www.trickylinux.net/add-domain-virtualminwebmin.html
http://codeboxlabs.com/add-subdomain-webmin-linux/
My current httpd.conf look like:
<VirtualHost *:80>
SSLEngine off
DocumentRoot /var/www/html/******/web
DirectoryIndex index.php
<Directory "/var/www/html/*****/web">
AllowOverride All
Allow from All
</Directory>
ServerName www.******.com
ServerAlias ftp.*****.com
SSLEngine off
SSLVerifyClient optional
</VirtualHost>
Please help me to solve this issue.
I know its been a year and you must have found a path already but its for the future reference.
Just add another host:
<VirtualHost *:80>
DocumentRoot /var/www/html/******/subdomain
DirectoryIndex index.php
<Directory "/var/www/html/*****/subdomain">
AllowOverride All
Allow from All
</Directory>
ServerName www.subdomain.******.com
ServerAlias subdomain.******.com
SSLEngine off
SSLVerifyClient optional
</VirtualHost>
Of course restarting apache is needed in order to make it read the new VHost
What you need to do next is add an A record in you domain registrar (i.e, Godaddy). Record name will be your "subdomain" and it'll point to your server address:
A-----------------> # --------------------> ******.com
A-----------------> ******.com------------> ******.com
A-----------------> subdomian.******.com--> ******.com
Could anyone please help me with setting up this virtual host on my WAMP server?
I have read through several posts and blogs online and unable to get this set up.
I followed the procedure suggested here: http://www.ruifeio.com/2011/01/30/setting-up-virtual-hosts-on-wampserver/
When I do the above, my server hangs up. Presently I added the following to my C:/windows/system32/drivers/etc/hosts file
127.0.0.1 tsg.local
And I changed my httpd.conf Apache config file with Listen 90 since I am using Port 90
Plus, removed # tag as suggested in the above tutorial.
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
I also added the following to my httpd-vhosts.conf
<VirtualHost *:90>
ServerAdmin webmaster#localhost
DocumentRoot “C:\wamp\www\tsg\”
ServerName tsg.local
ErrorLog “C:\wamp\www\logs\tsg.log”
CustomLog “C:/wamp/www/logs/common.log” common
</VirtualHost>
And changed: NameVirtualHost *:80 to NameVirtualHost *:90
Thanks for helping out in advance!
If your server will start fine with the Virtual Host block removed, try fixing your quotes. It looks like you have some "magic quotes" instead of straight quotes - likely from copy and pasting from the tutorial. Try this instead:
<VirtualHost *:90>
ServerAdmin webmaster#localhost
DocumentRoot "C:\wamp\www\tsg\"
ServerName tsg.local
ErrorLog "C:\wamp\www\logs\tsg.log"
CustomLog "C:/wamp/www/logs/common.log" common
</VirtualHost>
You also might want to pick a more standard port to listen on, 8080 or 8888 rather than 90 if 80 is not an option.
Some details
XAMPP 1.7.1
OS tested on vista and xp
Hello everyone. I have some problems with configuring my virtual hosts.
Currently I have two sites.
Here is my vhost.conf file:
<VirtualHost *:80>
ServerAdmin me#site.nl
DocumentRoot c:/xampp/htdocs/site1/trunk/
ServerName site1.local
</VirtualHost>
<VirtualHost *:80>
ServerAdmin me#site.nl
DocumentRoot c:/xampp/htdocs/site2/trunk/
ServerName site2.local
</VirtualHost>
And of course in my host file I have
127.0.0.1 site1.local
127.0.0.1 site2.local
I have restarted apache as well as my browser various times.
Here is my problem:
http://site1.local works. But when i go to http://site2.local, I land at site1.local.
any idea's?
Try
<VirtualHost "site1.local">
ServerAdmin spam#a1230912##ad#.nl
DocumentRoot c:/xampp/htdocs/site1/trunk/
ServerName site1.local
</VirtualHost>
<VirtualHost "site2.local">
ServerAdmin spam#a1230912##ad#.nl
DocumentRoot c:/xampp/htdocs/site2/trunk/
ServerName site2.local
</VirtualHost>
You always get site1 because Apache default to the first.
edit
Uncomment
#NameVirtualHost *
to
NameVirtualHost *
In your httpd.conf
Mine says (/etc/httpd/conf/httpd.conf)
126 # Listen: Allows you to bind Apache to specific IP addresses and/or
127 # ports, in addition to the default. See also the <VirtualHost>
128 # directive.
129 #
130 # Change this to Listen on specific IP addresses as shown below to
131 # prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
132 #
133 Listen 127.0.0.1:80
134 NameVirtualHost 127.0.0.1
And my vhost file has
<VirtualHost "www.whatever.com">
DocumentRoot /var/www/html/whatever/pub
ErrorLog logs/error_log
ServerName www.whatever.com
...