jdlcgarcia
jdlcgarcia

Reputation: 183

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:

MAINWORDPRESS

ANOTHERWORDPRESS

LASTWORDPRESS

PRESTASHOP

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!!

Upvotes: 0

Views: 26

Answers (1)

Panama Jack
Panama Jack

Reputation: 24478

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.

https://httpd.apache.org/docs/2.4/vhosts/name-based.html#alg

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.

Upvotes: 1

Related Questions