Home > Net >  Apache virtual host subdomains not working
Apache virtual host subdomains not working

Time:12-08

I am using httpd-vhosts.conf,apache version 2.4.51 and Windows Server. The subdomain is not working.

httpd-vhosts.conf:

NameVirtualHost *:80

#
<VirtualHost *:80>
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DocumentRoot "e:/wamp64/www/mydomain.com"
    <Directory  "e:/wamp64/www/mydomain.com/">
        Options  Indexes  Includes  FollowSymLinks  MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

#
<VirtualHost *:80>
    ServerName subdomain.mydomain.com
    ServerAlias subdomain.mydomain.com
    DocumentRoot "e:/wamp64/www/mydomain.com/subdomain"
    <Directory  "e:/wamp64/www/mydomain.com/subdomain/">
        Options  Indexes  Includes  FollowSymLinks  MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Both mydomain.com and www.mydomain.com works great!

But if i try using: http://subdomain.mydomain.com i always got the error:

Hmm. We’re having trouble finding that site.

We can’t connect to the server at subdomain.mydomain.com

If that address is correct, here are three other things you can try:

    Try again later.
    Check your network connection.
    If you are connected but behind a firewall, check that Firefox has permission to access the Web.

hosts file is correct too:

127.0.0.1   mydomain.com
::1 mydomain.com

127.0.0.1   subdomain.mydomain.com
::1 subdomain.mydomain.com

P.S. I can access it directly from the host machine, but i can't on another device.

Why only the subdomain is not working, please? What am i missing?

Thank you!!!

CodePudding user response:

It seems to be more a DNS problem than a config problem on your serveur. Did you set any DNS for your subdomain ? Maybe you could find some help here :

https://www.godaddy.com/help/create-a-subdomain-4080

  • Related