jdlcgarcia jdlcgarcia - 1 year ago 76
Apache Configuration Question

My server's IP is redirecting to one folder automatically

I've an account in Digitalocean, they gave me my droplet's IP address and I have a lot of proyects separated in folders, mainly wordpress, prestashop and html.

ls -l www/
drwxrwxr-x 5 www-data www-data 4096 sep 17 12:36 mainwordpress
drwxr-xr-x 20 www-data www-data 4096 may 7 2015 anotherwordpress
drwxrwxr-x 6 www-data www-data 4096 sep 17 13:21 lastwordpress
drwxr-xr-x 6 www-data www-data 4096 ago 11 2015 prestashop
drwxr-xr-x 6 www-data www-data 4096 abr 1 2015 html

I have some domains that point to each and every wordpress and prestahop folders, so I could make the installation correctly and I can access them without an error. But when I try to access my HTML proyect, which has no domain and I access it via http://my_server_ip/html, it redirects me to one of the wordpress proyects, exactly to mainwordpress, and of course giving an error of not finding the page (404).

I've checked my domain's configuration, and every wordpress proyect has an A register to my server's IP, also the prestashop:


  • A: @ my_server_ip

  • A: subdomain my_server_ip

  • CNAME: www mainwordpress.com

  • CNAME: *.subdomain subdomain.mainwordpress.com

  • MX: 0 mainwordpress.com


  • A: @ my_server_ip

  • A: sub1 my_server_ip

  • A: sub2 my_server_ip

  • A: sub3 my_server_ip

  • A: www my_server_ip

  • A: * my_server_ip

  • CNAME: *.subdomain subdomain.anotherwordpress.com


  • A: @ my_server_ip

  • A: sub my_server_ip

  • CNAME: www lastwordpress.com.

  • CNAME: *.sub sub.lastwordpress.com.


  • A: @ my_server_ip

  • CNAME: www my_prestashop.com.

I'm completely lost. When I try to enter an URL via my server's IP (http://my_server_ip/html, or http://my_server_ip/whatever, or http://my_server_ip/askdhjfgaksjhdfgs) it goes to mainwordpress' 404 page. What other configurations should I look?

Thank you in advance!!

Answer Source

The default name-based vhost for an IP and port combination If no matching ServerName or ServerAlias is found in the set of virtual hosts containing the most specific matching IP address and port combination, then the first listed virtual host that matches that will be used.


Your problem is most likely the order of your virtual hosts. Unless you specify the IP address in the ServerAlias directive it uses the first virtual host as the default host if navigating from the server IP. So however your setup is, apache is reading your mainwordpress vhost first.

You can change the order and make html first or try adding the server ip to the ServerAlias directive on the html vhost.

Then restart Apache.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download