Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
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.
| |
|
Topic: Subdomain redirects to main domain |
|
Author |
|
thgtang
Joined: 27 Mar 2017 Posts: 1
|
Posted: Mon 27 Mar '17 7:53 Post subject: Subdomain redirects to main domain |
|
|
I have a site www.mysite.com (hosting in ubuntu 16) and I would like to make mail.mysite.com as the subdomain to access my roundcube webmail. The problem is whenever I tried to access the mail.mysite.com, it will redirect to www.mysite.com automatically. I tried to refer to to other similar questions here but it's still unsolved.
Here is my file settings
/etc/hosts
Code: |
127.0.0.1 localhost mail.localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
In the /etc/apache2/sites-available, i have mysite.com.conf, mysite.com-ssl.conf and mail.mysite.com.conf |
mail.mysite.com.conf
Code: | <VirtualHost *:80>
ServerName mail.mysite.com
DocumentRoot /var/www/roundcube
<Directory /var/www/roundcube>
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost> |
If you need to have the content of other files, please let me know.
Thank you for your help! |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Mon 27 Mar '17 19:39 Post subject: Re: Subdomain redirects to main domain |
|
|
thgtang wrote: |
Order allow,deny
Allow from all
Require all granted
| I doubt this is the problem but you are using 2.4 obviously and only need the "Require all granted" line.
The Order/allow/deny/satisfy is the old pre-2.4 syntax.
What probably is the problem is the first vhost must be a copy of the main host (www.). Which is in apache2.conf (I think).
Usually this is enough to get vhosts working.
Code: | <VirtualHost _default_:80>
DocumentRoot /var/www/wherever-the-main-site-is
</VirtualHost>
<VirtualHost *:80>
ServerName mail.mysite.com
DocumentRoot /var/www/roundcube
...
|
|
|
Back to top |
|
|
|
|
|
|